aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/fonts/dogicapixel.ttfbin0 -> 33556 bytes
-rw-r--r--assets/level1.json26
-rw-r--r--assets/level1.tmx24
-rw-r--r--assets/musics/Juhani Junkala [Retro Game Music Pack] Ending.wavbin0 -> 7876878 bytes
-rw-r--r--config.wren1
-rw-r--r--entities/player_entity.wren31
-rw-r--r--game_state.wren21
-rw-r--r--layer_type.wren6
-rw-r--r--level_map.wren42
-rw-r--r--levels/level1.wren11
-rw-r--r--main.wren5
-rw-r--r--screens/credit_screen.wren83
-rw-r--r--screens/menu_screen.wren46
13 files changed, 236 insertions, 60 deletions
diff --git a/assets/fonts/dogicapixel.ttf b/assets/fonts/dogicapixel.ttf
new file mode 100644
index 0000000..bd3ebe8
--- /dev/null
+++ b/assets/fonts/dogicapixel.ttf
Binary files differ
diff --git a/assets/level1.json b/assets/level1.json
index 5b1ce14..fe44270 100644
--- a/assets/level1.json
+++ b/assets/level1.json
@@ -35,19 +35,29 @@
"y":0
},
{
- "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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",
+ "draworder":"topdown",
+ "id":5,
+ "name":"objects",
+ "objects":[
+ {
+ "height":16,
+ "id":1,
+ "name":"player",
+ "rotation":0,
+ "type":"player",
+ "visible":true,
+ "width":16,
+ "x":16,
+ "y":32
+ }],
"opacity":1,
- "type":"tilelayer",
+ "type":"objectgroup",
"visible":true,
- "width":20,
"x":0,
"y":0
}],
- "nextlayerid":5,
- "nextobjectid":1,
+ "nextlayerid":6,
+ "nextobjectid":2,
"orientation":"orthogonal",
"renderorder":"right-down",
"tiledversion":"1.5.0",
diff --git a/assets/level1.tmx b/assets/level1.tmx
index d92b54d..e767d39 100644
--- a/assets/level1.tmx
+++ b/assets/level1.tmx
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<map version="1.5" tiledversion="1.5.0" orientation="orthogonal" renderorder="right-down" width="20" height="15" tilewidth="16" tileheight="16" infinite="0" nextlayerid="5" nextobjectid="1">
+<map version="1.5" tiledversion="1.5.0" orientation="orthogonal" renderorder="right-down" width="20" height="15" tilewidth="16" tileheight="16" infinite="0" nextlayerid="6" nextobjectid="2">
<editorsettings>
<export target="level1.json" format="json"/>
</editorsettings>
@@ -42,23 +42,7 @@
127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,127
</data>
</layer>
- <layer id="4" name="Tile Layer 3" width="20" height="15">
- <data encoding="csv">
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,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
-</data>
- </layer>
+ <objectgroup id="5" name="objects">
+ <object id="1" name="player" type="player" x="16" y="32" width="16" height="16"/>
+ </objectgroup>
</map>
diff --git a/assets/musics/Juhani Junkala [Retro Game Music Pack] Ending.wav b/assets/musics/Juhani Junkala [Retro Game Music Pack] Ending.wav
new file mode 100644
index 0000000..5160703
--- /dev/null
+++ b/assets/musics/Juhani Junkala [Retro Game Music Pack] Ending.wav
Binary files differ
diff --git a/config.wren b/config.wren
index 64278c7..290324d 100644
--- a/config.wren
+++ b/config.wren
@@ -39,5 +39,6 @@ class Config {
setupFonts() {
Font.load("font_title", "assets/fonts/lunchds.ttf", 20)
+ Font.load("font_minecraft", "assets/fonts/dogicapixel.ttf", 8)
}
} \ No newline at end of file
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
diff --git a/game_state.wren b/game_state.wren
index 9390261..42e1189 100644
--- a/game_state.wren
+++ b/game_state.wren
@@ -1,12 +1,27 @@
import "audio" for AudioEngine
import "dome" for Window
-
+import "screens/menu_screen" for MenuScreen
+import "screens/credit_screen" for CreditScreen
+import "levels/level1" for Level1
+import "levels/level2" for Level2
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")
AudioEngine.load("select","assets/sfx/select.wav")
+ AudioEngine.load("credit","assets/musics/Juhani Junkala [Retro Game Music Pack] Ending.wav")
_fullScreen = false
+
+ setupStates()
+ }
+
+ setupStates() {
+ __gameStates = {
+ "menu": MenuScreen,
+ "credit": CreditScreen,
+ "level1": Level1,
+ "level2": Level2
+ }
}
toggleFullscreen() {
@@ -16,8 +31,8 @@ class GameState {
switch(level) {
AudioEngine.stopAllChannels()
- _currentLevel = level.new(this)
- System.print("Current Level : %(level.name)")
+ _currentLevel = __gameStates[level].new(this)
+ System.print("Current Level : %(__gameStates[level].name)")
}
update() {
diff --git a/layer_type.wren b/layer_type.wren
index cee6b82..fb1f5c5 100644
--- a/layer_type.wren
+++ b/layer_type.wren
@@ -2,4 +2,10 @@
class LayerType {
static Tile { "tilelayer" }
static Object { "objectgroup" }
+}
+
+class ObjectType {
+ static PLAYER { "player" }
+ static NPC { "npc" }
+ static ENEMY { "enemy" }
} \ No newline at end of file
diff --git a/level_map.wren b/level_map.wren
index 2bfb941..88ce9c6 100644
--- a/level_map.wren
+++ b/level_map.wren
@@ -1,8 +1,8 @@
import "json" for Json
import "graphics" for ImageData
import "math" for Math
-import "./layer_type" for LayerType
-
+import "./layer_type" for LayerType, ObjectType
+import "./entities/player_entity" for Player
class LevelMap {
construct new(mapName) {
_mapData = Json.load("assets/%(mapName).json")
@@ -17,9 +17,45 @@ class LevelMap {
_layers = _mapData["layers"]
_rows = Math.floor(_tileSheetW/_tileW)
_cols = Math.floor(_tileSheetH/_tileH)
+ _playerPos = {
+ "x": 0,
+ "y": 0
+ }
+ placeObjects()
+
+ }
+
+ playerPos = (position) {
+ _playerPos = position
+ }
+
+ playerPos { _playerPos }
+
+ placeObjects() {
+ for(layer in _layers) {
+ if(layer["type"] == LayerType.Object) {
+ for(object in layer["objects"]) {
+ if(object["type"]==ObjectType.PLAYER) {
+ playerPos = {
+ "x": object["x"],
+ "y": object["y"]
+ }
+ _player = Player.new(playerPos["x"], playerPos["y"])
+ }
+ }
+ }
+ }
+ }
+
+ draw(dt) {
+ _player.draw(dt)
+ }
+
+ update() {
+ _player.update()
}
- draw(x, y) {
+ render(x, y) {
var startX = x
var startY = y
for(layer in _layers) {
diff --git a/levels/level1.wren b/levels/level1.wren
index 83d626f..d113a25 100644
--- a/levels/level1.wren
+++ b/levels/level1.wren
@@ -1,17 +1,24 @@
import "./level_map" for LevelMap
import "audio" for AudioEngine
-class Level1 {
+import "./controls" for Controls
+import "./config" for Config
+class Level1 {
construct new(gameState) {
+ __gameState = gameState
_level1 = LevelMap.new("level1")
var channel = AudioEngine.play("level1_bg")
channel.volume = 0.2
}
update() {
+ if(Controls.justPressed(Config.KeyboardConstants["ATTACK"])) {
+ }
+ _level1.update()
}
draw(dt) {
- _level1.draw(0,0)
+ _level1.render(0,0)
+ _level1.draw(dt)
}
} \ No newline at end of file
diff --git a/main.wren b/main.wren
index d166950..273c841 100644
--- a/main.wren
+++ b/main.wren
@@ -3,10 +3,9 @@ import "json" for Json
import "graphics" for Canvas, Color
import "dome" for Window, Process
import "math" for Math
-import "config" for Config
+import "./config" for Config
import "./controls" for Controls
import "./game_state" for GameState
-import "./screens/menu_screen" for MenuScreen
class Main {
construct new() {
@@ -15,7 +14,7 @@ class Main {
init() {
Config.new()
__gameState = GameState.new()
- __gameState.switch(MenuScreen)
+ __gameState.switch("menu")
}
update() {
diff --git a/screens/credit_screen.wren b/screens/credit_screen.wren
index 3b54d2b..59128ba 100644
--- a/screens/credit_screen.wren
+++ b/screens/credit_screen.wren
@@ -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
+ }
+ }
}
} \ No newline at end of file
diff --git a/screens/menu_screen.wren b/screens/menu_screen.wren
index e065765..ea712d3 100644
--- a/screens/menu_screen.wren
+++ b/screens/menu_screen.wren
@@ -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))
+ }
+
+
+ }
+
}
/*