diff options
author | Indrajith K L | 2021-08-03 17:53:10 +0530 |
---|---|---|
committer | Indrajith K L | 2021-08-03 17:53:10 +0530 |
commit | 705886d371cf2cfa619b321c0d87caca0773a789 (patch) | |
tree | 0e860ca10c6cfd122b403b02e84d4fef72078b63 /entities/player_entity.wren | |
parent | 5bd12d5a658c1cd710bc950be971ebe3993ed11d (diff) | |
download | rebirth-wren-705886d371cf2cfa619b321c0d87caca0773a789.tar.gz rebirth-wren-705886d371cf2cfa619b321c0d87caca0773a789.tar.bz2 rebirth-wren-705886d371cf2cfa619b321c0d87caca0773a789.zip |
Bug Fixes
Player Placement
Basic Player Movement
Diffstat (limited to 'entities/player_entity.wren')
-rw-r--r-- | entities/player_entity.wren | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/entities/player_entity.wren b/entities/player_entity.wren new file mode 100644 index 0000000..194bb5f --- /dev/null +++ b/entities/player_entity.wren @@ -0,0 +1,31 @@ +import "graphics" for ImageData, Canvas +import "./controls" for Controls +import "./config" for Config +class Player { + construct new(x,y) { + _x = x + _y = y + + _playerSprite = ImageData.loadFromFile("assets/sprites/player.png") + } + + update() { + if(Controls.isKeyDown(Config.KeyboardConstants["UP"])) { + _y = _y - 1 + } + if(Controls.isKeyDown(Config.KeyboardConstants["DOWN"])) { + _y = _y + 1 + } + if(Controls.isKeyDown(Config.KeyboardConstants["LEFT"])) { + _x = _x - 1 + } + if(Controls.isKeyDown(Config.KeyboardConstants["RIGHT"])) { + _x = _x + 1 + } + } + + draw(dt) { + Canvas.draw(_playerSprite,_x,_y) + } + +}
\ No newline at end of file |