Compare commits
No commits in common. "bc1a251842f54cd692a0d751b518c69a6a718bc6" and "56d46512284272ac9d3cd252eb996f357ca9535a" have entirely different histories.
bc1a251842
...
56d4651228
47
hGameTest/src/Game.hx
Normal file
47
hGameTest/src/Game.hx
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
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,9 +1,6 @@
|
|||||||
import openfl.events.KeyboardEvent;
|
|
||||||
import openfl.display.Sprite;
|
import openfl.display.Sprite;
|
||||||
import openfl.display.Stage;
|
import openfl.display.Stage;
|
||||||
import openfl.events.Event;
|
import openfl.events.Event;
|
||||||
import game.Game;
|
|
||||||
|
|
||||||
class Main extends Sprite {
|
class Main extends Sprite {
|
||||||
public function new () {
|
public function new () {
|
||||||
super ();
|
super ();
|
||||||
@ -11,8 +8,6 @@ class Main extends Sprite {
|
|||||||
var game:Game = new Game(stage);
|
var game:Game = new Game(stage);
|
||||||
game.onInit();
|
game.onInit();
|
||||||
stage.addEventListener(Event.ENTER_FRAME, game.onEnterFrame);
|
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.addEventListener(Event.RESIZE,onResize);
|
||||||
stage.application.window.resize(1920, 1080);
|
stage.application.window.resize(1920, 1080);
|
||||||
stage.application.window.title = "Kanker";
|
stage.application.window.title = "Kanker";
|
||||||
@ -22,12 +17,5 @@ class Main extends Sprite {
|
|||||||
//Here we can do shit with window scaling
|
//Here we can do shit with window scaling
|
||||||
//stage.stageWidth;
|
//stage.stageWidth;
|
||||||
//stage.stageHeight;
|
//stage.stageHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function keyIsDown(e:KeyboardEvent){
|
|
||||||
Game.keys[e.keyCode] = true;
|
|
||||||
}
|
|
||||||
private function keyIsUp(e:KeyboardEvent){
|
|
||||||
Game.keys[e.keyCode] = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,18 +1,13 @@
|
|||||||
package assets.tilesets;
|
package assets.tilesets;
|
||||||
|
|
||||||
import openfl.display.BitmapData;
|
|
||||||
|
|
||||||
class Tileset{
|
class Tileset{
|
||||||
public static var tilesetMap:Map<String, Tileset> = [];
|
public static var tilesetMap:Map<String, Tileset> = [];
|
||||||
|
|
||||||
public var texName:String;
|
public var texName:String;
|
||||||
public var texAtlas:TextureAtlas;
|
public var texAtlas:TextureAtlas;
|
||||||
public var tileMap:Map<String,BitmapData>;
|
|
||||||
public function new(name:String, atlas:TextureAtlas){
|
public function new(name:String, atlas:TextureAtlas){
|
||||||
texName = name;
|
texName = name;
|
||||||
texAtlas = atlas;
|
texAtlas = atlas;
|
||||||
tilesetMap[name] = this;
|
tilesetMap[name] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -2,12 +2,12 @@ package assets.tilesets;
|
|||||||
|
|
||||||
import openfl.display.BitmapData;
|
import openfl.display.BitmapData;
|
||||||
import assets.tilesets.TextureAtlas;
|
import assets.tilesets.TextureAtlas;
|
||||||
import assets.tilesets.Tileset;
|
|
||||||
|
|
||||||
class TilesetGeneric extends Tileset{
|
class TilesetGeneric extends Tileset{
|
||||||
|
public var tileMap:Map<String, BitmapData> = [];
|
||||||
public function new(name:String, atlas:TextureAtlas ,tileNames:Array<String>){
|
public function new(name:String, atlas:TextureAtlas ,tileNames:Array<String>){
|
||||||
super(name,atlas);
|
super(name,atlas);
|
||||||
tileMap = [];
|
|
||||||
for(i in 0...texAtlas.sprites.length-1){
|
for(i in 0...texAtlas.sprites.length-1){
|
||||||
trace(i);
|
trace(i);
|
||||||
trace(tileNames[i]);
|
trace(tileNames[i]);
|
||||||
|
|||||||
@ -1,63 +0,0 @@
|
|||||||
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++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
package game.entities;
|
|
||||||
|
|
||||||
import openfl.display.Sprite;
|
|
||||||
|
|
||||||
|
|
||||||
class BaseRenderable extends BaseEntity{
|
|
||||||
public var sprite:Sprite;
|
|
||||||
public function new(){
|
|
||||||
super();
|
|
||||||
sprite = new Sprite();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
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