* Menu Screen

* SFX
* Player Sprites
This commit is contained in:
Indrajith K L
2021-08-03 02:22:07 +05:30
parent f2e4f56366
commit 5bd12d5a65
13 changed files with 1107 additions and 29 deletions

BIN
assets/sfx/select.wav Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 728 B

Binary file not shown.

BIN
assets/sprites/player.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 B

File diff suppressed because one or more lines are too long

Binary file not shown.

BIN
assets/sprites/render.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -38,7 +38,6 @@ class Config {
} }
setupFonts() { setupFonts() {
Font.load("font_medium", "assets/fonts/lunchds.ttf", 20) Font.load("font_title", "assets/fonts/lunchds.ttf", 20)
Font.load("font_small", "assets/fonts/lunchds.ttf", 16)
} }
} }

View File

@@ -5,6 +5,7 @@ class GameState {
construct new() { construct new() {
AudioEngine.load("menu_music","assets/musics/04 All of Us - Menu.ogg") 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") AudioEngine.load("level1_bg","assets/musics/01 A Night Of Dizzy Spells.ogg")
AudioEngine.load("select","assets/sfx/select.wav")
_fullScreen = false _fullScreen = false
} }

View File

@@ -1,25 +0,0 @@
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)
}
}

View File

@@ -6,7 +6,7 @@ import "math" for Math
import "config" for Config import "config" for Config
import "./controls" for Controls import "./controls" for Controls
import "./game_state" for GameState import "./game_state" for GameState
import "./levels/menu" for Menu import "./screens/menu_screen" for MenuScreen
class Main { class Main {
construct new() { construct new() {
@@ -15,7 +15,7 @@ class Main {
init() { init() {
Config.new() Config.new()
__gameState = GameState.new() __gameState = GameState.new()
__gameState.switch(Menu) __gameState.switch(MenuScreen)
} }
update() { update() {

View File

@@ -0,0 +1,13 @@
class CreditScreen {
construct new() {
}
update() {
}
draw(dt) {
}
}

105
screens/menu_screen.wren Normal file
View File

@@ -0,0 +1,105 @@
import "graphics" for Canvas, Color
import "./controls" for Controls
import "config" for Config
import "levels/level1" for Level1
import "screens/credit_screen" for CreditScreen
import "audio" for AudioEngine
import "font" for Font
import "math" for Math
class MenuScreen {
construct new(gameState) {
__gameState = gameState
// var channel = AudioEngine.play("menu_music")
// channel.volume = 0.5
_selectedMenuIdx = 0
_prevMenuIdx = 0
_fadeFrame = 255
_menuItems = [
{
"name": "Start",
"selected": true,
"class": Level1,
"font": Font.default,
"padding": 20
},
{
"name": "Credits",
"selected": false,
"class": CreditScreen,
"font": Font.default,
"padding": 40
}
]
}
update() {
if(Controls.isKeyDown(Config.KeyboardConstants["SELECT"])) {
__gameState.switch(Level1)
}
if(Controls.justPressed(Config.KeyboardConstants["UP"])) {
_prevMenuIdx = _selectedMenuIdx
if((_selectedMenuIdx-1) < 0) {
_selectedMenuIdx = (_menuItems.count - 1)
} else {
_selectedMenuIdx = _selectedMenuIdx - 1
}
AudioEngine.play("select")
}
if(Controls.justPressed(Config.KeyboardConstants["DOWN"])) {
_prevMenuIdx = _selectedMenuIdx
if((_selectedMenuIdx+1) > (_menuItems.count - 1)) {
_selectedMenuIdx = 0
} else {
_selectedMenuIdx = _selectedMenuIdx + 1
}
AudioEngine.play("select")
}
if(_prevMenuIdx!=_selectedMenuIdx) {
_menuItems[_prevMenuIdx]["selected"] = false
_menuItems[_selectedMenuIdx]["selected"] = true
}
// _fadeFrame = (_fadeFrame+3) > 255 ? 0 : _fadeFrame + 3
_fadeFrame = Math.floor(127 + (127 * Math.cos(System.clock)))
System.print(_fadeFrame)
}
draw(dt) {
drawTitle()
for(menuItem in _menuItems) {
drawMenu(menuItem)
}
drawBlinker()
}
drawTitle() {
Canvas.print("REBIRTH",Config.W/2 - 40,Config.H/2 - 20, Color.white, "font_title")
}
drawMenu(menuItem) {
var x = Config.W/2 - ((menuItem["name"].count * 8)/2)
var y = Config.H/2 + menuItem["padding"]
Canvas.print(menuItem["name"],x ,y , menuItem["selected"] ? Color.red : Color.white, menuItem["font"])
if(menuItem["selected"]) {
Canvas.print(">",x - 10 ,y , Color.red, menuItem["font"])
}
// Canvas.print("Credits", Config.W/2 - 28, Config.H/2 + 40, Color.white, Font.default)
}
drawBlinker() {
Canvas.print("Press X to start",Config.W/2 - 64,Config.H/2 + 100, Color.new(255, 255, 255, _fadeFrame), Font.default)
}
}
/*
(Character length * 8 ) / 2
*/