Created
June 23, 2016 00:11
-
-
Save DCubix/27d7a1491740def3692b8c109ff692f7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package; | |
import cpp.Lib; | |
import sys.FileSystem; | |
import sys.io.File; | |
import com.sgtek.sengine.core.Game; | |
import com.sgtek.sengine.core.ResourceLoader; | |
/** | |
* ... | |
* @author TwisterGE | |
*/ | |
class Main extends Game { | |
public function new() { | |
super("Test", 640, 480, GraphicsMode.Scaled4x4); | |
} | |
static function main() : Void { | |
var test : Main = new Main(); | |
test.start(); | |
} | |
override public function preload(loader: ResourceLoader) { | |
loader.addResource("px", "bin/px.png", DataType.DataImage); | |
} | |
override public function init() { | |
currentStage = new MainStage(this); | |
} | |
} |
This file contains hidden or 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
package; | |
import com.sgtek.sengine.core.Game; | |
import com.sgtek.sengine.core.GameObject; | |
import com.sgtek.sengine.core.Point; | |
import com.sgtek.sengine.core.Stage; | |
import com.sgtek.sengine.core.MathF; | |
import com.sgtek.sengine.graphics.Sprite; | |
/** | |
* ... | |
* @author TwisterGE | |
*/ | |
class MainStage extends Stage | |
{ | |
private var t : Float; | |
private var pb : GameObject; | |
public function new(game: Game) { | |
super(game); | |
} | |
override public function init() { | |
super.init(); | |
var px = game.loader.getImage("px"); | |
pb = new GameObject(new Sprite(px)); | |
pb.origin = new Point(0.5, 0.5); | |
pb.position.y = game.height / 2; | |
addObject(pb); | |
} | |
override public function update(d: Float) { | |
t += d; | |
if (MathF.rad2deg(t) >= 360) { | |
t = 0; | |
} | |
var hw = game.width / 2; | |
pb.position.x = hw * Math.sin(t) + hw; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment