First commit
This commit is contained in:
28
hGameTest/src/App.hx
Normal file
28
hGameTest/src/App.hx
Normal file
@@ -0,0 +1,28 @@
|
||||
import openfl.display.Sprite;
|
||||
import openfl.display.Stage;
|
||||
import openfl.events.Event;
|
||||
|
||||
|
||||
class App extends Sprite {
|
||||
|
||||
|
||||
public function new () {
|
||||
|
||||
super ();
|
||||
var game:Game = new Game(stage);
|
||||
game.onInit();
|
||||
stage.addEventListener(Event.ENTER_FRAME, game.onEnterFrame);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
static function main () {
|
||||
|
||||
var stage = new Stage (550, 400, 0xFFFFFF, App);
|
||||
js.Browser.document.body.appendChild (stage.element);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
33
hGameTest/src/Game.hx
Normal file
33
hGameTest/src/Game.hx
Normal file
@@ -0,0 +1,33 @@
|
||||
import openfl.display.Bitmap;
|
||||
import openfl.display.Stage;
|
||||
import openfl.display.Bitmap;
|
||||
import openfl.display.BitmapData;
|
||||
import openfl.display.Sprite;
|
||||
import openfl.events.Event;
|
||||
import openfl.Assets;
|
||||
|
||||
class Game
|
||||
{
|
||||
public var stage:Stage;
|
||||
public function new(_stage:Stage){
|
||||
stage = _stage;
|
||||
}
|
||||
public var player:Sprite;
|
||||
public function onInit():Void
|
||||
{
|
||||
player = new Sprite();
|
||||
stage.addChild(player);
|
||||
//player.graphics.lineStyle(2,0xFF0000);
|
||||
//player.graphics.drawRect(0,0,16,16);
|
||||
var bitmapData:BitmapData = Assets.getBitmapData("sprites/character.png");
|
||||
var playerBitmap:Bitmap = new Bitmap(bitmapData);
|
||||
playerBitmap.scaleX = playerBitmap.scaleY = 10;
|
||||
player.addChild(playerBitmap);
|
||||
//Sys.
|
||||
}
|
||||
public function onEnterFrame(e:Event):Void
|
||||
{
|
||||
//player.x++;
|
||||
//player.y++;
|
||||
}
|
||||
}
|
||||
21
hGameTest/src/Main.hx
Normal file
21
hGameTest/src/Main.hx
Normal file
@@ -0,0 +1,21 @@
|
||||
import openfl.display.Sprite;
|
||||
import openfl.display.Stage;
|
||||
import openfl.events.Event;
|
||||
class Main extends Sprite {
|
||||
public function new () {
|
||||
super ();
|
||||
stage.frameRate = 1000;
|
||||
var game:Game = new Game(stage);
|
||||
game.onInit();
|
||||
stage.addEventListener(Event.ENTER_FRAME, game.onEnterFrame);
|
||||
stage.addEventListener(Event.RESIZE,onResize);
|
||||
stage.application.window.resize(1920, 1080);
|
||||
stage.application.window.title = "Kanker";
|
||||
|
||||
}
|
||||
private function onResize (event:Event):Void {
|
||||
//Here we can do shit with window scaling
|
||||
//stage.stageWidth;
|
||||
//stage.stageHeight;
|
||||
}
|
||||
}
|
||||
16
hGameTest/src/SpriteSheet.hx
Normal file
16
hGameTest/src/SpriteSheet.hx
Normal file
@@ -0,0 +1,16 @@
|
||||
import openfl.display.BitmapData;
|
||||
import openfl.display.Bitmap;
|
||||
class SpriteSheet{
|
||||
public static var spriteSheetArray:Array<SpriteSheet> = [];
|
||||
public var sprites:Array<Bitmap> = [];
|
||||
public function new(bmp:Bitmap = null, sprWidth:Int = 16, sprHeight:Int = 16){
|
||||
spriteSheetArray.push(this);
|
||||
var columns:Int = cast((bmp.width / sprWidth),Int);
|
||||
var rows:Int = cast((bmp.height / sprHeight),Int);
|
||||
for(i in 0...columns){
|
||||
for (j in 0...rows){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user