Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
donatomodugno committed May 14, 2024
1 parent 8975ce3 commit 3ee6691
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
13 changes: 7 additions & 6 deletions README
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
WEEE Open Game - Developed by WEEE Open student team, 2024
WARNING - WORK IN PROGRESS, DOCUMENTATION NOT FINISHED YET

-- How does this works?
The root of the project is the index.html file, which loads each js module.
The root of the project is the index.html file, which loads each js module from the /src folder.
The modules loaded are, in order:
1. Utils (utils.js)
2. Assets (assets.js)
Expand All @@ -23,10 +22,10 @@ Usually Utils contains math functions and other frequent operations.

-- 3. Scenes
List of scenes in the format scene_xxx. Each scene must implement four methods:
-- 3.1. xxxSceneInit():
-- 3.2. xxxSceneKeyPress(key):
-- 3.3. xxxSceneKeyRelease(key):
-- 3.4. xxxSceneLoop():
-- 3.1. xxxSceneInit()
-- 3.2. xxxSceneKeyPress(key)
-- 3.3. xxxSceneKeyRelease(key)
-- 3.4. xxxSceneLoop()

-- 4. Transition
It's a "special scene" that overlaps others while changing a scene.
Expand All @@ -36,3 +35,5 @@ It does not have methods about inputs (key press, key release)
It's the "global scene" that executes the code in each one of the four methods regardless of which scene is active

-- 6. Inputs
Contains the listeners for input events.
Moreover it separates functions to be called before and after that the page is fully loaded.
5 changes: 3 additions & 2 deletions src/assets.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Global variables and functions */
const VERSION = '0.1.3'
const VERSION = '0.1.4'
const MOBILE = navigator.userAgent.match(/mobile/i) ? true : false
const [W,H] = [1024,576]//[960,540]
const keys = {
Expand Down Expand Up @@ -52,7 +52,7 @@ const music = {
theme5:{audio:new Audio('res/music/sound_of_infinity_f777.mp3'),volume:0.4},
}
const sounds = {
screw:{audio:new Audio('res/sounds/coin.wav'),volume:0.8},
screw:{audio:new Audio('res/sounds/coin.wav'),volume:0.3},
death:{audio:new Audio('res/sounds/death.wav'),volume:0.6},
jetpack:{audio:new Audio('res/sounds/jetpack.wav'),loop:true,volume:0.4}
}
Expand Down Expand Up @@ -95,6 +95,7 @@ function soundPlay(sound) {
const clone = sounds[sound].audio.cloneNode()
clone.volume = sounds[sound].audio.volume
clone.play()
clone.remove()
}
}

Expand Down
1 change: 1 addition & 0 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
function mainInit() {
display.scene = 'menu'
display.transition = false
window[display.scene+'SceneInit']()
}

function mainKeyPress(key) {
Expand Down
12 changes: 4 additions & 8 deletions src/scene_menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ const MENU_COLOR_SUBTITLE = '#bbb'
const MENU_SQUARE_SIZE = W/8
const MENU_MAXTICK_SQUARES = 50

const menu = {
ticks:{
squares:0,
}
}
const menu = {}

function menuSceneInit() {
return
menu.ticks = {squares:0}
}

function menuSceneKeyPress(key) {
Expand All @@ -32,8 +28,8 @@ function menuSceneLoop() {
renderRect(MENU_SQUARE_SIZE*i,84+16*Math.sin(i+menu.ticks.squares/8),MENU_SQUARE_SIZE+1,MENU_SQUARE_SIZE*2,MENU_COLOR_SUBTITLE)
ctx.resetTransform()
renderText('WEEE OPEN GAME',W/2,H*5/12,MENU_COLOR_TITLE,{centered:true,font:'Emulogic',size:1.8})
renderText('Use WASD to move',W/2,H*6/8,MENU_COLOR_SUBTITLE,{centered:true,font:'Emulogic',size:0.8})
renderText('Press space to start game',W/2,H*5/6,MENU_COLOR_SUBTITLE,{centered:true,font:'Emulogic',size:0.8})
renderText('WASD: move',W/2,H*6/8,MENU_COLOR_SUBTITLE,{centered:true,font:'Emulogic',size:0.8})
renderText('Space: start game',W/2,H*5/6,MENU_COLOR_SUBTITLE,{centered:true,font:'Emulogic',size:0.8})
renderText('Version: '+VERSION,10,H-10,'white',{font:'Emulogic',size:0.4})
}
function update() {
Expand Down

0 comments on commit 3ee6691

Please sign in to comment.