Permalink
Browse files

Making jeff happier with camelCase.

  • Loading branch information...
1 parent b343d82 commit 1d0d174b3e7d67418d140e83b09aadf3e8dfab4f @mcgrue mcgrue committed Oct 22, 2010
Showing with 53 additions and 30 deletions.
  1. +20 −20 src/game/GameState.as
  2. +22 −4 src/game/HittableBlock.as
  3. +11 −6 src/game/Player.as
View
@@ -7,11 +7,11 @@ package game {
public var map:FlxTilemap;
public var obs:FlxTilemap;
- public var map_group:FlxGroup = new FlxGroup();
- public var obs_group:FlxGroup = new FlxGroup();
- public var objects_group:FlxGroup = new FlxGroup();
- public var plr_group:FlxGroup = new FlxGroup();
- public static const obstructed_tiles:Array = [4,17,18,19,33,34,35];
+ public var mapGroup:FlxGroup = new FlxGroup();
+ public var obstructionGroup:FlxGroup = new FlxGroup();
+ public var objectsGroup:FlxGroup = new FlxGroup();
+ public var playerGroup:FlxGroup = new FlxGroup();
+ public static const obstructedTiles:Array = [4,17,18,19,33,34,35];
[Embed (source = "../../data/tilesets/mario.png")] private var marioTiles:Class;
[Embed (source = "../../data/sprites/hit_block.png")] private var hittableTile:Class;
@@ -26,15 +26,15 @@ package game {
}
public static function is_obstruction_tile(idx:int):Boolean {
- return obstructed_tiles.indexOf(idx) >= 0;
+ return obstructedTiles.indexOf(idx) >= 0;
}
override public function create():void {
- add(obs_group);
- add(map_group);
- add(objects_group);
- add(plr_group);
+ add(obstructionGroup);
+ add(mapGroup);
+ add(objectsGroup);
+ add(playerGroup);
var xml:XML = new XML( new marioMap );
var mapxml:XMLList = xml.*;
@@ -57,7 +57,7 @@ package game {
16, 16
);
- obs_group.add(obs);
+ obstructionGroup.add(obs);
for( var x:int = 0; x<obs.widthInTiles; x++ ) {
for( var y:int = 0; y<obs.heightInTiles; y++ ) {
@@ -69,9 +69,9 @@ package game {
var hb:HittableBlock = new HittableBlock(x*16, y*16, 16, 16);
hb.loadTiles(hittableTile, 16, 16);
- hb.collideLeft = false;
- hb.collideRight = false;
- objects_group.add(hb);
+ //hb.collideLeft = false;
+ //hb.collideRight = false;
+ objectsGroup.add(hb);
map.setTile(x, y, 1);
}
@@ -81,20 +81,20 @@ package game {
}
}
- map_group.add(map);
+ mapGroup.add(map);
//map.visible = false;
- plr_group.add( new Player(4*16,9*16,1) );
- plr_group.add( new Player(11*16,9*16,3) );
+ playerGroup.add( new Player(4*16,9*16,1) );
+ playerGroup.add( new Player(11*16,9*16,3) );
super.create();
}
public function before_update(): void {
- FlxU.collide(plr_group, obs_group);
- FlxU.collide(plr_group, plr_group);
- FlxU.collide(plr_group, objects_group);
+ FlxU.collide(playerGroup, obstructionGroup);
+ FlxU.collide(playerGroup, playerGroup);
+ FlxU.collide(playerGroup, objectsGroup);
}
public function after_update(): void {
View
@@ -1,11 +1,14 @@
package game {
+ import game.Player;
+
+ import org.flixel.FlxObject;
import org.flixel.FlxTileblock;
public class HittableBlock extends FlxTileblock {
public var is_bouncing:Boolean = false;
- private var orig_x:int;
- private var orig_y:int;
+ public var orig_x:int;
+ public var orig_y:int;
public const GRAVITY:int = 640;
public const JUMP_FORCE:int = 1280;
@@ -20,12 +23,12 @@ package game {
acceleration.y = GRAVITY;
}
- public function doBounce(inertia:int):void {
+ public function doBounce(inertia_x:int, intertia_y:int):void {
if( is_bouncing ) {
return;
}
- velocity.y = -Math.abs(inertia);
+ velocity.y = -Math.abs(intertia_y);
// bounce everyone atop of it.
@@ -34,6 +37,21 @@ package game {
is_bouncing = true;
}
+ override public function preCollide(Contact:FlxObject):void {
+
+ /*
+ if( Contact is Player ) {
+
+ var p:Player = Contact as Player;
+
+ if( orig_y < p.y ) {
+ p.velocity.y = 0;
+ p.y = orig_y;
+ }
+ }
+ */
+ }
+
public override function update():void {
if( is_bouncing ) {
View
@@ -1,4 +1,5 @@
package game {
+
import org.flixel.*;
public class Player extends WrappingSprite {
@@ -10,7 +11,7 @@ package game {
public const GRAVITY:int = 1200;
public const JUMP_FORCE:int = 1200;
public const JUMP_HOLD_FORCE:int = 150;
- public const MAX_VELOCITY:int = 300;
+ public const MAX_VELOCITY:int = 320;
public const IMPACT_MULTIPLIER:Number = 2;
@@ -37,7 +38,7 @@ package game {
case 3: P=4; break;
case 4: P=6; break;
}
-
+
var f1:Number = (P);
var f2:Number = (P+1);
@@ -122,11 +123,15 @@ package game {
override public function preCollide(Contact:FlxObject):void {
if( Contact is HittableBlock ) {
- if( y > Contact.y ) {
- var hb:HittableBlock = Contact as HittableBlock;
+
+ var hb:HittableBlock = Contact as HittableBlock;
+
+ if( y > (hb.orig_y) && y <= (hb.orig_y+16) ) {
+
+ hb.doBounce( velocity.x, velocity.y );
- hb.doBounce(velocity.y);
- velocity.y = -velocity.y;
+ y = hb.orig_y+16;
+ velocity.y = 0;
}
} else if( Contact is Player ) {
Contact.velocity.x = -(Contact.velocity.x*IMPACT_MULTIPLIER);

0 comments on commit 1d0d174

Please sign in to comment.