-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added moving platforms and zero gravity plugin
- Loading branch information
Showing
16 changed files
with
265 additions
and
9 deletions.
There are no files selected for viewing
Binary file not shown.
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
Binary file not shown.
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,105 @@ | ||
package entities; | ||
|
||
import entities.Platform.PlatformSprite; | ||
import flixel.FlxG; | ||
import flixel.FlxObject; | ||
import flixel.util.FlxMath; | ||
import flixel.util.FlxPath; | ||
import flixel.util.FlxPoint; | ||
import networkobj.NEmitter; | ||
import networkobj.NSprite; | ||
import networkobj.NTemplate; | ||
import networkobj.NFlxSprite; | ||
import networkobj.NReg; | ||
import ext.FlxEmitterAuto; | ||
import flixel.tile.FlxTilemap; | ||
import gevents.HurtInfo; | ||
import gevents.HurtEvent; | ||
import gamemodes.BaseGamemode; | ||
import haxe.xml.Fast; | ||
import gamemodes.DefaultHooks; | ||
|
||
/** | ||
* ... | ||
* @author ... | ||
*/ | ||
|
||
class Platform extends NSprite | ||
{ | ||
static public var TEMPL:NTemplate; | ||
|
||
public var speed:Int; | ||
public var nodes:Array<FlxPoint>; | ||
public var mode:Int; | ||
|
||
public function new(X:Float, Y:Float, Nodes:Array<FlxPoint>, Mode:Int, Speed:Int = 100) | ||
{ | ||
nodes = Nodes; | ||
mode = Mode; | ||
speed = Speed; | ||
|
||
super(X, Y, TEMPL, PlatformSprite); | ||
} | ||
|
||
override public function announce(PlayerID:Int):Void | ||
{ | ||
super.announce(PlayerID); | ||
|
||
setFields(0, ["health"], [0]); | ||
} | ||
|
||
static public function makeFromXML(D:Fast):Platform | ||
{ | ||
var speed:Int = Std.parseInt(D.att.Speed); | ||
var mode:String = D.att.Mode; | ||
var realmode:Int = FlxPath.LOOP_FORWARD; | ||
if (mode == "YOYO") | ||
realmode = FlxPath.YOYO; | ||
var nodes:Array<FlxPoint> = []; | ||
nodes.push(new FlxPoint(Std.parseInt(D.att.x), Std.parseInt(D.att.y))); | ||
|
||
for (n in D.elements) | ||
{ | ||
if (n.name == "node") | ||
{ | ||
nodes.push(new FlxPoint(Std.parseInt(n.att.x), Std.parseInt(n.att.y))); | ||
} | ||
} | ||
|
||
return new Platform(Std.parseInt(D.att.x), Std.parseInt(D.att.y), nodes, realmode, speed); | ||
} | ||
|
||
static public function init():Void | ||
{ | ||
TEMPL = new NTemplate("assets/images/platform.png", 0, 0, 400); | ||
NReg.registerTemplate(TEMPL); | ||
} | ||
} | ||
|
||
class PlatformSprite extends NFlxSprite | ||
{ | ||
public var platform:Platform; | ||
|
||
public function new(X:Float, Y:Float, GraphicString:String, Parent:Platform) | ||
{ | ||
super(X, Y, GraphicString, Parent); | ||
|
||
platform = Parent; | ||
|
||
var path:FlxPath = new FlxPath(this, platform.nodes, platform.speed, platform.mode); | ||
} | ||
|
||
override public function update():Void | ||
{ | ||
FlxG.collide(this, Reg.state.players, collisionHandler); | ||
FlxG.overlap(Reg.state.bullets, this, DefaultHooks.bulletCollide); | ||
|
||
super.update(); | ||
} | ||
|
||
private function collisionHandler(Platf:PlatformSprite, Pl:Player):Void | ||
{ | ||
Pl.velocity.y = Platf.velocity.y; | ||
Pl.velocity.x = Platf.velocity.x; | ||
} | ||
} |
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,101 @@ | ||
package plugins; | ||
|
||
import entities.MeteoriteStrike.Meteor; | ||
import flixel.util.FlxPoint; | ||
import flixel.util.FlxRandom; | ||
import flixel.util.FlxTimer; | ||
import gamemodes.BaseGamemode; | ||
import gevents.GenEvent; | ||
import networkobj.NLabel; | ||
import gamemodes.DefaultHooks; | ||
import ext.FlxMarkup; | ||
import gevents.RespawnEvent; | ||
|
||
/** | ||
* ... | ||
* @author ... | ||
*/ | ||
class SysGravity extends BasePlugin | ||
{ | ||
public var gravityWorking:Bool = true; | ||
|
||
private var msg:NLabel; | ||
|
||
public function new() | ||
{ | ||
pluginName = "SysGravity"; | ||
version = "0.0.1"; | ||
|
||
super(); | ||
} | ||
|
||
override public function hookEvents(Gm:BaseGamemode):Void | ||
{ | ||
super.hookEvents(Gm); | ||
|
||
Gm.addEventListener(RespawnEvent.RESPAWN_EVENT, onSpawn, false, 10); | ||
} | ||
|
||
override public function onSpawn(E:GenEvent):Void | ||
{ | ||
super.onSpawn(E); | ||
|
||
var p:Player = cast E.info; | ||
|
||
if (gravityWorking) | ||
{ | ||
p.acceleration.y = 440; | ||
} | ||
else | ||
{ | ||
p.acceleration.y = 0; | ||
} | ||
} | ||
|
||
public function ruinPhysics(Timer:FlxTimer = null):Void | ||
{ | ||
announceRuin(); | ||
new FlxTimer(6, ruinGravity); | ||
new FlxTimer(16, undo); | ||
} | ||
|
||
private function ruinGravity(Timer:FlxTimer = null):Void | ||
{ | ||
gravityWorking = false; | ||
|
||
for (p in Reg.server.playermap.iterator()) | ||
{ | ||
p.acceleration.y = 50; | ||
} | ||
} | ||
|
||
private function fixGravity(Timer:FlxTimer = null):Void | ||
{ | ||
gravityWorking = true; | ||
|
||
for (p in Reg.server.playermap.iterator()) | ||
{ | ||
p.acceleration.y = 440; | ||
} | ||
} | ||
|
||
private function announceRuin():Void | ||
{ | ||
msg = new NLabel(180, 100, 0xffffffff, 0, true); | ||
msg.setLabel("Losing artificial gravity!"); | ||
new FlxTimer(6, deleteAnnounce); | ||
} | ||
|
||
private function undo(Timer:FlxTimer = null):Void | ||
{ | ||
msg = new NLabel(140, 100, 0xffffffff, 0, true); | ||
msg.setLabel("Reestablishing artificial gravity. Get to solid ground!"); | ||
new FlxTimer(6, fixGravity); | ||
new FlxTimer(6, deleteAnnounce); | ||
} | ||
|
||
private function deleteAnnounce(T:FlxTimer):Void | ||
{ | ||
msg.delete(); | ||
} | ||
} |
Oops, something went wrong.