Bug Fixes

Player Placement
Basic Player Movement
This commit is contained in:
Indrajith K L
2021-08-03 17:53:10 +05:30
parent 5bd12d5a65
commit 705886d371
13 changed files with 236 additions and 60 deletions

View File

@@ -1,13 +1,88 @@
class CreditScreen {
construct new() {
import "./controls" for Controls
import "./config" for Config
import "audio" for AudioEngine
import "font" for Font
import "graphics" for Canvas, Color
class CreditScreen {
construct new(gameState) {
__gameState = gameState
var channel = AudioEngine.play("credit", 0.5, true)
__credits = [
{
"text": "A GAME BY",
"padding": 10,
"type": "title"
},
{
"text": "Indrajith K L",
"padding": 30
},
{
"text": "TILESETS & SPRITES",
"padding": 50,
"type": "title"
},
{
"text": "kenney.nl",
"padding": 70
},
{
"text": "MUSIC",
"padding": 90,
"type": "title"
},
{
"text": "Juhani Junkala & Eric Skiff",
"padding": 110
},
{
"text": "SFX",
"padding": 130,
"type": "title"
},
{
"text": "sfxr",
"padding": 150
},
{
"text": "For More Games",
"padding": 170,
"type": "title"
},
{
"text": "indrajithmakesgames.com",
"padding": 190,
"type": "info"
}
]
}
update() {
if(Controls.justPressed(Config.KeyboardConstants["ATTACK"])) {
__gameState.switch("menu")
}
}
draw(dt) {
var x = 0
var y = 10
for(credit in __credits) {
drawCredit(credit, x, y)
var y = y + 10
}
}
drawCredit(credit, x, y) {
x = Config.W/2 - ((credit["text"].count * 8)/2)
y = credit["padding"] + y
Canvas.print(credit["text"],x ,y , Color.white, credit["type"]=="info" ? "font_minecraft": Font.default)
if(credit["type"]=="title") {
x = x
for(i in 0...(credit["text"].count)) {
Canvas.print("-",x ,y+8 , Color.white, Font.default)
x = x + 8
}
}
}
}

View File

@@ -1,42 +1,41 @@
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 "./config" for Config
import "audio" for AudioEngine
import "font" for Font
import "math" for Math
import "dome" for Platform
class MenuScreen {
construct new(gameState) {
__gameState = gameState
// var channel = AudioEngine.play("menu_music")
// channel.volume = 0.5
var channel = AudioEngine.play("menu_music", 0.5, true)
_selectedMenuIdx = 0
_prevMenuIdx = 0
_fadeFrame = 255
_fadeSelector = 255
_menuItems = [
{
"name": "Start",
"selected": true,
"class": Level1,
"state": "level1",
"font": Font.default,
"padding": 20
},
{
"name": "Credits",
"selected": false,
"class": CreditScreen,
"state": "credit",
"font": Font.default,
"padding": 40
}
]
_time = 0
}
update() {
if(Controls.isKeyDown(Config.KeyboardConstants["SELECT"])) {
__gameState.switch(Level1)
if(Controls.justPressed(Config.KeyboardConstants["ATTACK"])) {
__gameState.switch(_menuItems[_selectedMenuIdx]["state"])
}
if(Controls.justPressed(Config.KeyboardConstants["UP"])) {
@@ -63,11 +62,13 @@ class MenuScreen {
_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)
_fadeSelector = inOutQuad(_time, 0, 255, 50)
if (_time>51) {
_time = 0
} else {
_time = _time + 1
}
}
draw(dt) {
@@ -90,14 +91,25 @@ class MenuScreen {
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(">",x - 10 ,y , Color.new(255, 0, 77, _fadeSelector), 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)
Canvas.print("Press X to select",Config.W/2 - 64,Config.H/2 + 100, Color.new(255, 255, 255, _fadeFrame), Font.default)
}
inOutQuad(t, b, c, d) {
t = t / d * 2
if( t < 1 ) {
return Math.abs(Math.floor(((c / 2) * (t.pow(2))) + b))
} else {
return Math.abs(Math.floor(((-c / 2) * ((t - 1) * (t - 3) - 1)) + b))
}
}
}
/*