From f2e4f563661e5203f0531e37110d060b20b2f04c Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Mon, 2 Aug 2021 17:10:03 +0530 Subject: * Adds Music Management * Code Refactoring * Adds Fonts --- CREDITS.md | 5 ++ assets/fonts/lunchds.ttf | Bin 0 -> 10656 bytes assets/level1.json | 22 +++--- assets/level1.tmx | 101 +++++++++++++-------------- assets/musics/01 A Night Of Dizzy Spells.ogg | Bin 0 -> 2552548 bytes assets/musics/04 All of Us - Menu.ogg | Bin 0 -> 3850371 bytes config.wren | 41 ++++++----- controls.wren | 6 +- game_state.wren | 14 +++- levels/level1.wren | 7 +- levels/menu.wren | 25 +++++++ main.wren | 18 ++--- 12 files changed, 146 insertions(+), 93 deletions(-) create mode 100644 CREDITS.md create mode 100644 assets/fonts/lunchds.ttf create mode 100644 assets/musics/01 A Night Of Dizzy Spells.ogg create mode 100644 assets/musics/04 All of Us - Menu.ogg create mode 100644 levels/menu.wren diff --git a/CREDITS.md b/CREDITS.md new file mode 100644 index 0000000..63331e9 --- /dev/null +++ b/CREDITS.md @@ -0,0 +1,5 @@ +## Credits + +**Tileset & Sprites** : kenney.nl + +**Music** : Eric Skiff - Song Name - Resistor Anthems - Available at http://EricSkiff.com/music diff --git a/assets/fonts/lunchds.ttf b/assets/fonts/lunchds.ttf new file mode 100644 index 0000000..9acccd4 Binary files /dev/null and b/assets/fonts/lunchds.ttf differ diff --git a/assets/level1.json b/assets/level1.json index ea69794..5b1ce14 100644 --- a/assets/level1.json +++ b/assets/level1.json @@ -7,42 +7,42 @@ "target":"level1.json" } }, - "height":16, + "height":15, "infinite":false, "layers":[ { - "data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":15, "id":4, "name":"Tile Layer 3", "opacity":1, "type":"tilelayer", "visible":true, - "width":16, + "width":20, "x":0, "y":0 }], @@ -69,5 +69,5 @@ "tilewidth":16, "type":"map", "version":1.5, - "width":16 + "width":20 } \ No newline at end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0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,120,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 diff --git a/assets/musics/01 A Night Of Dizzy Spells.ogg b/assets/musics/01 A Night Of Dizzy Spells.ogg new file mode 100644 index 0000000..d2d1702 Binary files /dev/null and b/assets/musics/01 A Night Of Dizzy Spells.ogg differ diff --git a/assets/musics/04 All of Us - Menu.ogg b/assets/musics/04 All of Us - Menu.ogg new file mode 100644 index 0000000..24989f3 Binary files /dev/null and b/assets/musics/04 All of Us - Menu.ogg differ diff --git a/config.wren b/config.wren index a1b8cec..eb085c1 100644 --- a/config.wren +++ b/config.wren @@ -1,10 +1,17 @@ import "graphics" for Canvas import "dome" for Window +import "font" for Font + class Config { construct new() { - + __width = 320 + __height = 240 + setup() } + static W {__width} + static H {__height} + static KeyboardConstants { return { "UP": "up", @@ -14,26 +21,24 @@ class Config { "PICK" : "c", "SELECT": "z", "ATTACK": "x", - "QUIT": "escape" + "QUIT": "escape", + "FULLSCREEN": "f" } } - static setup() { - Window.resize(800, 600) - Canvas.resize(800, 600) - Window.title = "REBIRTH" + setup() { + setupWindow() + setupFonts() } - // static KeyboardConstants() { - // return { - // "UP": "up", - // "DOWN": "down", - // "LEFT": "left", - // "RIGHT": "right", - // "PICK" : "c", - // "SELECT": "z", - // "ATTACK": "x", - // "QUIT": "esc" - // } - // } + setupWindow() { + Window.resize(__width*2, __height*2) + Canvas.resize(__width, __height) + Window.title = "REBIRTH" + } + + setupFonts() { + Font.load("font_medium", "assets/fonts/lunchds.ttf", 20) + Font.load("font_small", "assets/fonts/lunchds.ttf", 16) + } } \ No newline at end of file diff --git a/controls.wren b/controls.wren index 3804020..e8d9d81 100644 --- a/controls.wren +++ b/controls.wren @@ -5,7 +5,11 @@ class Controls { } - static detect(keyCode) { + static isKeyDown(keyCode) { return Keyboard.isKeyDown(keyCode) } + + static justPressed(keyCode) { + return Keyboard[keyCode].justPressed + } } \ No newline at end of file diff --git a/game_state.wren b/game_state.wren index 94e8a99..4794fb7 100644 --- a/game_state.wren +++ b/game_state.wren @@ -1,10 +1,22 @@ +import "audio" for AudioEngine +import "dome" for Window + class GameState { construct new() { + AudioEngine.load("menu_music","assets/musics/04 All of Us - Menu.ogg") + AudioEngine.load("level1_bg","assets/musics/01 A Night Of Dizzy Spells.ogg") + _fullScreen = false + } + toggleFullscreen() { + _fullScreen = !_fullScreen + Window.fullscreen = _fullScreen } switch(level) { - _currentLevel = level.new() + AudioEngine.stopAllChannels() + _currentLevel = level.new(this) + System.print("Current Level : %(level.name)") } update() { diff --git a/levels/level1.wren b/levels/level1.wren index c485924..83d626f 100644 --- a/levels/level1.wren +++ b/levels/level1.wren @@ -1,9 +1,12 @@ import "./level_map" for LevelMap +import "audio" for AudioEngine class Level1 { - construct new() { + construct new(gameState) { _level1 = LevelMap.new("level1") + var channel = AudioEngine.play("level1_bg") + channel.volume = 0.2 } - + update() { } diff --git a/levels/menu.wren b/levels/menu.wren new file mode 100644 index 0000000..dcc24e9 --- /dev/null +++ b/levels/menu.wren @@ -0,0 +1,25 @@ +import "graphics" for Canvas, Color +import "./controls" for Controls +import "config" for Config +import "levels/level1" for Level1 +import "audio" for AudioEngine +import "font" for Font + +class Menu { + construct new(gameState) { + __gameState = gameState + var channel = AudioEngine.play("menu_music") + channel.volume = 0.5 + Canvas.font = "font_medium" + } + + update() { + if(Controls.isKeyDown(Config.KeyboardConstants["SELECT"])) { + __gameState.switch(Level1) + } + } + + draw(dt) { + Canvas.print("REBIRTH",Config.W/2 - 40,Config.H/2 - 20, Color.white) + } +} \ No newline at end of file diff --git a/main.wren b/main.wren index 370860e..9e94aa3 100644 --- a/main.wren +++ b/main.wren @@ -4,31 +4,33 @@ import "graphics" for Canvas, Color import "dome" for Window, Process import "math" for Math import "config" for Config -import "input" for Keyboard import "./controls" for Controls import "./game_state" for GameState -import "./levels/level1" for Level1 +import "./levels/menu" for Menu class Main { construct new() { - Config.setup() - __gameState = GameState.new() - __gameState.switch(Level1) } init() { - + Config.new() + __gameState = GameState.new() + __gameState.switch(Menu) } update() { - if(Controls.detect(Config.KeyboardConstants["QUIT"])) { + if(Controls.isKeyDown(Config.KeyboardConstants["QUIT"])) { Process.exit(0) } + + if(Controls.justPressed(Config.KeyboardConstants["FULLSCREEN"])) { + __gameState.toggleFullscreen() + } __gameState.update() } draw(dt) { - Canvas.cls(Color.pink) + Canvas.cls(Color.black) __gameState.draw(dt) } } -- cgit v1.2.3