Skip to content

Commit

Permalink
strange
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerbraun committed Apr 6, 2012
1 parent feb958b commit a6c37e6
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
Binary file modified Main.swf
Binary file not shown.
23 changes: 18 additions & 5 deletions PlayState.as
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,47 @@ 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 _oneFood:FlxSprite;
private var _shells:FlxEmitter;

override public function create():void {

_snake = new Snake(8);
_snake = new Snake(2);
_food = initialFood();

_shells = new FlxEmitter();
_shells.makeParticles(Shell,4);

_oneFood = _food.members[0];

add(_snake);
add(_food);
add(_oneFood);
add(_shells);

}

override public function update():void {
FlxG.overlap(_snake.head(), _oneFood, eat);
super.update();
FlxG.overlap(_snake.head(), _food, eat);
}

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.makeGraphic(16,16,0xff00ff00);//loadGraphic(Egg);
group.add(food);
return group;
}
Expand Down
2 changes: 1 addition & 1 deletion Snake.as
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ package {
_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;

Expand Down
Binary file added assets/images/egg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/shell.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/sssnake01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a6c37e6

Please sign in to comment.