Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first attempt at first level. Mikey can go up stairs, woo!
- Loading branch information
Showing
9 changed files
with
204 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package | ||
{ | ||
import org.flixel.*; | ||
|
||
public class Level | ||
{ | ||
public var bricks:FlxGroup; | ||
public var ladders:FlxGroup; | ||
|
||
public function Level():void { | ||
bricks = new FlxGroup(); | ||
ladders = new FlxGroup(); | ||
} | ||
|
||
public function create():void | ||
{ | ||
|
||
} | ||
|
||
public function place_item(X:int,Y:int,Graphic:Class,Group:FlxGroup):FlxSprite | ||
{ | ||
var item:FlxSprite = new FlxSprite(X,Y,Graphic); | ||
Group.add(item); | ||
return item; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package levels | ||
{ | ||
import org.flixel.*; | ||
|
||
public class Level1 extends Level | ||
{ | ||
public var stairs:FlxGroup; | ||
|
||
[Embed(source="../../assets/brick.png")] private var ImgBrick:Class; | ||
[Embed(source="../../assets/ladder.png")] private var ImgLadder:Class; | ||
|
||
public function Level1():void | ||
{ | ||
super(); | ||
stairs = new FlxGroup(); | ||
} | ||
|
||
override public function create():void | ||
{ | ||
//bottom | ||
create_row(8,224,15); | ||
create_stairs(128,223,5); | ||
|
||
create_stairs(216,188,9,false,true); | ||
|
||
create_stairs(32,158,9,true,true); | ||
|
||
create_stairs(216,128,9,false,true); | ||
|
||
create_stairs(32,98,9,true,true); | ||
|
||
create_stairs(216,68,4,false); | ||
|
||
place_ladder(10,10,2); | ||
|
||
//top | ||
create_row(16,64,14); | ||
create_row(104,40,6); | ||
} | ||
|
||
public function create_row(X:uint,Y:uint,count:uint):void | ||
{ | ||
var i:uint = 0; | ||
for(i; i < count; i++) place_brick(X+i*8,Y); | ||
} | ||
|
||
public function create_stairs(X:int,Y:int,count:int,right:Boolean=true,shorten_last:Boolean=false):void | ||
{ | ||
var i:uint = 0; | ||
var j:uint = 0; | ||
var x_offset:int = 0; | ||
var y_offset:int = 0; | ||
for(i; i < count; i++) | ||
{ | ||
var length:int = shorten_last && i+1==count? 2 : 3; | ||
for(j = 0; j < length; j++) | ||
{ | ||
var brick:FlxSprite = place_item(X+x_offset,Y+y_offset,ImgBrick,stairs); | ||
brick.immovable = true; | ||
x_offset += right? brick.width : -brick.width; | ||
} | ||
y_offset -= 1; | ||
} | ||
} | ||
|
||
public function place_brick(X:int,Y:int):void | ||
{ | ||
var brick:FlxSprite = place_item(X,Y,ImgBrick,bricks); | ||
brick.immovable = true; | ||
} | ||
|
||
public function place_ladder(X:int,Y:int,height:int):void | ||
{ | ||
var ladder:FlxSprite = place_item(X,Y,ImgLadder,ladders); | ||
var i:uint = 0; | ||
for(i; i < height; i++) ladder.stamp(ladder,0,i*8); | ||
} | ||
} | ||
} |
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package | ||
{ | ||
import flash.display.Sprite; | ||
import flash.events.ErrorEvent; | ||
//import flash.events.UncaughtErrorEvent; | ||
import flash.external.ExternalInterface; | ||
|
||
public class Console extends Sprite | ||
{ | ||
public function Console():void | ||
{ | ||
super(); | ||
init(); | ||
} | ||
|
||
public static function log(... arguments):void | ||
{ | ||
Console.trace(arguments); | ||
} | ||
|
||
public static function warn(... arguments):void | ||
{ | ||
Console.trace(arguments, "warn"); | ||
} | ||
|
||
public static function error(... arguments):void | ||
{ | ||
Console.trace(arguments, "error"); | ||
} | ||
|
||
private static function trace(args:Object,type:String = "log"):void | ||
{ | ||
for(var i:String in args) | ||
{ | ||
if( !args[i] is String) | ||
args[i] = args[i].toString(); | ||
ExternalInterface.call("console."+type,args[i]); | ||
if( type == "log") trace(args[i]); | ||
} | ||
} | ||
|
||
private function init():void | ||
{ | ||
//if(loaderInfo.hasOwnProperty("uncaughtErrorEvents")) | ||
//loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, uncaughtErrorHandler, false, 0, true); | ||
} | ||
|
||
/*private function uncaughtErrorHandler(e:UncaughtErrorEvent):void | ||
{ | ||
if( e.error is Error) | ||
{ | ||
var stack:String = Error(e.error).getStackTrace(); | ||
Console.error(Error(e.error).message + ((stack!=null)? "\n"+stack : "")); | ||
} | ||
else if( e.error is ErrorEvent) | ||
Console.error(ErrorEvent(e.error).text); | ||
else | ||
Console.error(e.error.toString()); | ||
}*/ | ||
} | ||
} |