-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
425 additions
and
26 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
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
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,113 @@ | ||
package | ||
{ | ||
import net.flashpunk.*; | ||
import net.flashpunk.graphics.*; | ||
import net.flashpunk.masks.*; | ||
import net.flashpunk.utils.*; | ||
import flash.utils.ByteArray; | ||
|
||
public class Overworld | ||
{ | ||
[Embed(source="images/tiles.png")] public static const TilesGfx: Class; | ||
|
||
[Embed(source="map.lvl", mimeType="application/octet-stream")] public static const MapData: Class; | ||
|
||
public static var tiles:Tilemap; | ||
|
||
public static const WIDTH:int = 512 - 16; | ||
public static const HEIGHT:int = 320 - 16; | ||
|
||
public static function init ():void | ||
{ | ||
tiles = new Tilemap(TilesGfx, WIDTH, HEIGHT, 16, 16); | ||
|
||
tiles.loadFromString(new MapData); | ||
|
||
reloadData(); | ||
} | ||
|
||
public static function reloadData ():void | ||
{ | ||
drawEdges(); | ||
} | ||
|
||
public static function drawEdges ():void | ||
{ | ||
tiles.updateAll(); | ||
|
||
var i:int, j:int; | ||
var a:uint, b:uint, c:uint; | ||
|
||
tiles.usePositions = true; | ||
|
||
for (i = 0; i < WIDTH; i += 1) { | ||
for (j = 16; j < HEIGHT; j += 16) { | ||
a = tiles.getTile(i, j - 1); | ||
b = tiles.getTile(i, j); | ||
|
||
if (a == b) continue; | ||
|
||
tiles.setPixel(i, j - FP.rand(2), Room.BLACK); | ||
|
||
var d:int = tileDiff(a, b); | ||
|
||
if (d) { | ||
c = color(a, b, d); | ||
|
||
d -= FP.rand(2); | ||
|
||
//c = FP.colorLerp(Room.BLACK, tiles.getPixel(i, j + d), 0.25); | ||
|
||
tiles.setPixel(i, j + d, c); | ||
} | ||
} | ||
} | ||
|
||
for (i = 16; i < WIDTH; i += 16) { | ||
for (j = 0; j < HEIGHT; j += 1) { | ||
a = tiles.getTile(i - 1, j); | ||
b = tiles.getTile(i, j); | ||
|
||
if (a == b) continue; | ||
|
||
tiles.setPixel(i - FP.rand(2), j, Room.BLACK); | ||
|
||
d = tileDiff(a, b); | ||
|
||
if (d) { | ||
c = color(a, b, d); | ||
|
||
d -= FP.rand(2); | ||
|
||
//c = FP.colorLerp(Room.BLACK, tiles.getPixel(i, j + d), 0.25); | ||
|
||
tiles.setPixel(i + d, j, c); | ||
} | ||
} | ||
} | ||
|
||
tiles.usePositions = false; | ||
} | ||
|
||
private static function tileDiff (a:uint, b:uint): int | ||
{ | ||
if (a == Room.WATER) return 2; | ||
if (b == Room.WATER) return -2; | ||
if (a == Room.ROCK) return -3; | ||
if (b == Room.ROCK) return 3; | ||
return 0; | ||
} | ||
|
||
private static function color (a:uint, b:uint, diff:int): uint | ||
{ | ||
var tile:uint = (diff > 0) ? b : a; | ||
|
||
if (tile == Room.ROCK) return Room.BLACK; | ||
if (tile == Room.GRASS) return 0xff265f49; | ||
|
||
return Room.BLACK; | ||
} | ||
|
||
} | ||
} | ||
|
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,73 @@ | ||
package | ||
{ | ||
import net.flashpunk.*; | ||
import net.flashpunk.graphics.*; | ||
import net.flashpunk.masks.*; | ||
import net.flashpunk.utils.*; | ||
|
||
import flash.display.*; | ||
|
||
public class RockSpit extends Entity | ||
{ | ||
[Embed(source="images/rockspit.png")] public static const RockGfx: Class; | ||
|
||
public var vx:Number = 0; | ||
public var vy:Number = 0; | ||
|
||
public var owner:Octorok = null; | ||
|
||
public function RockSpit (_x:Number, _y:Number, _vx:Number, _vy:Number, _owner:Octorok) | ||
{ | ||
super(_x, _y); | ||
|
||
vx = _vx; | ||
vy = _vy; | ||
|
||
owner = _owner; | ||
|
||
graphic = new Stamp(RockGfx, -8, -8); | ||
|
||
setHitbox(6, 6, 3, 3); | ||
|
||
type = "octorok_spit"; | ||
} | ||
|
||
public override function update ():void | ||
{ | ||
x += vx; | ||
y += vy; | ||
|
||
if (collide("projectile_solid", x, y)) { | ||
world.remove(this); | ||
} | ||
|
||
if (! onCamera) { | ||
visible = false; | ||
world.remove(this); | ||
} | ||
} | ||
|
||
public override function removed ():void | ||
{ | ||
if (! visible) return; | ||
|
||
var e:Emitter = new Emitter(foo, 2, 2); | ||
e.newType("a"); | ||
e.setMotion("a", 0, 10, 15, 360, 5, 10); | ||
e.setAlpha("a"); | ||
e.emit("a", x, y); | ||
e.emit("a", x, y); | ||
e.emit("a", x, y); | ||
e.emit("a", x, y); | ||
e.emit("a", x, y); | ||
e.emit("a", x, y); | ||
e.emit("a", x, y); | ||
e.emit("a", x, y); | ||
e.emit("a", x, y); | ||
FP.world.addGraphic(e); | ||
} | ||
|
||
public static const foo:BitmapData = new BitmapData(2, 2, false, 0x4e5159); | ||
} | ||
} | ||
|
Oops, something went wrong.