Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: rogerbraun/FlixelSnake
base: feb958ba70
...
head fork: rogerbraun/FlixelSnake
compare: 8d20533f94
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
View
BIN  Main.swf
Binary file not shown
View
16 PlayState.as
@@ -2,34 +2,44 @@ package {
import org.flixel.*;
public class PlayState extends FlxState {
+
+ [Embed(source='assets/images/egg.png')] protected var Egg:Class;
+ [Embed(source='assets/images/shell.png')] protected var Shell:Class;
private var _snake:Snake;
private var _food:FlxGroup;
+ private var _shells:FlxEmitter;
override public function create():void {
_snake = new Snake(8);
_food = initialFood();
+ _shells = new FlxEmitter();
+ _shells.makeParticles(Shell,4);
+
add(_snake);
add(_food);
+ add(_shells);
}
override public function update():void {
- super.update();
FlxG.overlap(_snake.head(), _food, eat);
+ super.update();
}
private function eat(snakeHead:FlxSprite, food:FlxSprite):void {
FlxG.shake();
+ _shells.at(food);
+ _shells.start();
food.kill();
}
private function initialFood():FlxGroup{
var group:FlxGroup = new FlxGroup;
- var food:FlxSprite = new FlxSprite(16,16);
- food.makeGraphic(16,16,0xffff0000);
+ var food:FlxSprite = new FlxSprite(16*5,16*5);
+ food.loadGraphic(Egg);
group.add(food);
return group;
}
View
20 Snake.as
@@ -8,11 +8,12 @@ package {
private var _speed:Number;
public function Snake(movesPerSecond:Number = 1) {
+ super();
_speed = 1 / movesPerSecond;
_timer = 0;
- _head = new FlxSprite(FlxG.width / 2, FlxG.height / 2);
+ _head = new FlxSprite(32,32);
_head.makeGraphic(16,16);
_head.facing = FlxObject.RIGHT;
@@ -53,30 +54,31 @@ package {
}
}
- _head.velocity.x = 0;
- _head.velocity.y = 0;
+ var xSpeed:int = 0;
+ var ySpeed:int = 0;
switch(_head.facing) {
case FlxObject.RIGHT:
- _head.velocity.x = 16;
+ xSpeed = 16;
break;
case FlxObject.LEFT:
- _head.velocity.x = -16;
+ xSpeed = -16;
break;
case FlxObject.UP:
- _head.velocity.y = -16;
+ ySpeed = -16;
break;
case FlxObject.DOWN:
- _head.velocity.y = 16;
+ ySpeed = 16;
break;
}
- _head.x += _head.velocity.x;
- _head.y += _head.velocity.y;
+ _head.x += xSpeed;
+ _head.y += ySpeed;
}
override public function update():void {
+ super.update();
if(FlxG.keys.UP){
_head.facing = FlxObject.UP;
View
BIN  assets/images/egg.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  assets/images/shell.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  assets/images/sssnake01.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

No commit comments for this range

Something went wrong with that request. Please try again.