Compare commits
4 Commits
56d4651228
...
bc1a251842
| Author | SHA1 | Date | |
|---|---|---|---|
| bc1a251842 | |||
| 8973b65954 | |||
| 132a9d63c0 | |||
| fbc3be26e4 |
@ -1,47 +0,0 @@
|
||||
import assets.tilesets.TilesetGeneric;
|
||||
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;
|
||||
import assets.Scanner;
|
||||
import assets.HTex;
|
||||
|
||||
|
||||
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("textures/sprites/character.png");
|
||||
Scanner.scanTextureDir();
|
||||
var sheetData:BitmapData = Assets.getBitmapData("textures/sheets/sheet.png");
|
||||
for(tex in Scanner.textures){
|
||||
HTex.createTextureObjectFromJSON(tex);
|
||||
}
|
||||
//var sheet:SpriteSheet = new SpriteSheet(sheetData);
|
||||
|
||||
var playerBitmap:Bitmap = new Bitmap(TilesetGeneric.tilesetGenericMap["testsheet"].tileMap["testTile5"]);
|
||||
var someotherbitmap:Bitmap = new Bitmap(TilesetGeneric.tilesetGenericMap["testsheet"].tileMap["testTile3"]);
|
||||
|
||||
playerBitmap.scaleX = playerBitmap.scaleY = 10;
|
||||
player.addChild(playerBitmap);
|
||||
//TextureData.parseConfig();
|
||||
//Sys.
|
||||
}
|
||||
public function onEnterFrame(e:Event):Void
|
||||
{
|
||||
//player.x++;
|
||||
//player.y++;
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,9 @@
|
||||
import openfl.events.KeyboardEvent;
|
||||
import openfl.display.Sprite;
|
||||
import openfl.display.Stage;
|
||||
import openfl.events.Event;
|
||||
import game.Game;
|
||||
|
||||
class Main extends Sprite {
|
||||
public function new () {
|
||||
super ();
|
||||
@ -8,6 +11,8 @@ class Main extends Sprite {
|
||||
var game:Game = new Game(stage);
|
||||
game.onInit();
|
||||
stage.addEventListener(Event.ENTER_FRAME, game.onEnterFrame);
|
||||
stage.addEventListener(KeyboardEvent.KEY_DOWN,keyIsDown);
|
||||
stage.addEventListener(KeyboardEvent.KEY_UP,keyIsUp);
|
||||
stage.addEventListener(Event.RESIZE,onResize);
|
||||
stage.application.window.resize(1920, 1080);
|
||||
stage.application.window.title = "Kanker";
|
||||
@ -18,4 +23,11 @@ class Main extends Sprite {
|
||||
//stage.stageWidth;
|
||||
//stage.stageHeight;
|
||||
}
|
||||
|
||||
private function keyIsDown(e:KeyboardEvent){
|
||||
Game.keys[e.keyCode] = true;
|
||||
}
|
||||
private function keyIsUp(e:KeyboardEvent){
|
||||
Game.keys[e.keyCode] = false;
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,18 @@
|
||||
package assets.tilesets;
|
||||
|
||||
import openfl.display.BitmapData;
|
||||
|
||||
class Tileset{
|
||||
public static var tilesetMap:Map<String, Tileset> = [];
|
||||
|
||||
public var texName:String;
|
||||
public var texAtlas:TextureAtlas;
|
||||
public var tileMap:Map<String,BitmapData>;
|
||||
public function new(name:String, atlas:TextureAtlas){
|
||||
texName = name;
|
||||
texAtlas = atlas;
|
||||
tilesetMap[name] = this;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -2,12 +2,12 @@ package assets.tilesets;
|
||||
|
||||
import openfl.display.BitmapData;
|
||||
import assets.tilesets.TextureAtlas;
|
||||
|
||||
import assets.tilesets.Tileset;
|
||||
|
||||
class TilesetGeneric extends Tileset{
|
||||
public var tileMap:Map<String, BitmapData> = [];
|
||||
public function new(name:String, atlas:TextureAtlas ,tileNames:Array<String>){
|
||||
super(name,atlas);
|
||||
tileMap = [];
|
||||
for(i in 0...texAtlas.sprites.length-1){
|
||||
trace(i);
|
||||
trace(tileNames[i]);
|
||||
|
||||
63
hGameTest/src/game/Game.hx
Normal file
63
hGameTest/src/game/Game.hx
Normal file
@ -0,0 +1,63 @@
|
||||
package game;
|
||||
|
||||
import game.entities.Player;
|
||||
import assets.tilesets.TilesetGeneric;
|
||||
import assets.tilesets.Tileset;
|
||||
import openfl.display.Bitmap;
|
||||
import openfl.display.Stage;
|
||||
import openfl.display.Bitmap;
|
||||
import openfl.display.BitmapData;
|
||||
import openfl.display.Sprite;
|
||||
import openfl.ui.Keyboard;
|
||||
import openfl.events.Event;
|
||||
import openfl.Assets;
|
||||
import assets.Scanner;
|
||||
import assets.HTex;
|
||||
import openfl.Lib;
|
||||
import openfl.display.StageDisplayState;
|
||||
|
||||
class Game
|
||||
{
|
||||
public var stage:Stage;
|
||||
public function new(_stage:Stage){
|
||||
stage = _stage;
|
||||
Scanner.scanTextureDir();
|
||||
for(tex in Scanner.textures){
|
||||
HTex.createTextureObjectFromJSON(tex);
|
||||
}
|
||||
}
|
||||
public var player:Player;
|
||||
public function onInit():Void
|
||||
{
|
||||
|
||||
//player.graphics.lineStyle(2,0xFF0000);
|
||||
//player.graphics.drawRect(0,0,16,16);
|
||||
// var bitmapData:BitmapData = Assets.getBitmapData("textures/sprites/character.png");
|
||||
player = new Player();
|
||||
stage.addChild(player.sprite);
|
||||
//var sheet:SpriteSheet = new SpriteSheet(sheetData);
|
||||
//var playerBitmap:Bitmap = new Bitmap(Tileset.tilesetMap["testsheet"].tileMap["testTile5"]);
|
||||
//var someotherbitmap:Bitmap = new Bitmap(Tileset.tilesetMap["testsheet"].tileMap["testTile3"]);
|
||||
//playerBitmap.scaleX = playerBitmap.scaleY = 10;
|
||||
//player.addChild(playerBitmap);
|
||||
//TextureData.parseConfig();
|
||||
//Sys.
|
||||
}
|
||||
public static var keys:Array<Bool> = [];
|
||||
public static var keysLast:Array<Bool> = [];
|
||||
public function onEnterFrame(e:Event):Void
|
||||
{
|
||||
trace(keys);
|
||||
if( keys[Keyboard.ALTERNATE] && keys[Keyboard.ENTER] && !keysLast[Keyboard.ALTERNATE] && !keysLast[Keyboard.ENTER] ){
|
||||
if(Lib.current.stage.displayState != StageDisplayState.FULL_SCREEN_INTERACTIVE){
|
||||
Lib.current.stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
|
||||
}
|
||||
else{
|
||||
Lib.current.stage.displayState = StageDisplayState.NORMAL;
|
||||
}
|
||||
}
|
||||
keysLast = keys;
|
||||
//player.x++;
|
||||
//player.y++;
|
||||
}
|
||||
}
|
||||
18
hGameTest/src/game/entities/BaseEntity.hx
Normal file
18
hGameTest/src/game/entities/BaseEntity.hx
Normal file
@ -0,0 +1,18 @@
|
||||
package game.entities;
|
||||
|
||||
class BaseEntity{
|
||||
|
||||
public static var entities:Array<BaseEntity> = [];
|
||||
public function new(){
|
||||
entities.push(this);
|
||||
}
|
||||
public function think(){
|
||||
|
||||
}
|
||||
public static function dothink(){
|
||||
for(entity in entities){
|
||||
entity.think();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
12
hGameTest/src/game/entities/BaseRenderable.hx
Normal file
12
hGameTest/src/game/entities/BaseRenderable.hx
Normal file
@ -0,0 +1,12 @@
|
||||
package game.entities;
|
||||
|
||||
import openfl.display.Sprite;
|
||||
|
||||
|
||||
class BaseRenderable extends BaseEntity{
|
||||
public var sprite:Sprite;
|
||||
public function new(){
|
||||
super();
|
||||
sprite = new Sprite();
|
||||
}
|
||||
}
|
||||
15
hGameTest/src/game/entities/Player.hx
Normal file
15
hGameTest/src/game/entities/Player.hx
Normal file
@ -0,0 +1,15 @@
|
||||
package game.entities;
|
||||
|
||||
import openfl.display.Bitmap;
|
||||
import assets.tilesets.Tileset;
|
||||
import assets.tilesets.TilesetGeneric;
|
||||
|
||||
class Player extends BaseRenderable{
|
||||
public function new(){
|
||||
super();
|
||||
sprite.addChild(new Bitmap(Tileset.tilesetMap["testsheet"].tileMap["testTile5"]));
|
||||
}
|
||||
override public function think(){
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user