Skip to content

Commit

Permalink
Minor fixes, updated to ver. 0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
donatomodugno committed Mar 11, 2024
1 parent f685092 commit 47d8227
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 37 deletions.
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
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.
Expand Down
Binary file modified res/background.pdn
Binary file not shown.
Binary file modified res/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/clouds.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes
5 changes: 3 additions & 2 deletions src/assets.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* Global variables and functions */
const VERSION = '0.1.1'
const MOBILE = navigator.userAgent.match(/mobile/i) ? true : false
const [W,H] = [1024,576]//[960,540]
const VERSION = 0.1
const keys = {
Enter:{pressed:false},
' ':{pressed:false},
Expand Down Expand Up @@ -37,7 +38,7 @@ const fonts = [
new FontFace('Emulogic','url(res/emulogic.ttf)'),
]
const sprites = {
character:{img:null,frames:4,slowness:8},
player:{img:null,frames:4,slowness:8},
screw:{img:null,frames:4,slowness:8},
amp:{img:null,frames:4,slowness:8},
background:{img:null,dw:W*6,dh:H,sw:768,sh:72},
Expand Down
3 changes: 2 additions & 1 deletion src/inputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
loadResources()

/* After page loaded */
addEventListener('load',() => {
if(MOBILE) alert('Game not available on mobile devices')
else addEventListener('load',() => {
mainInit()
mainLoop()

Expand Down
35 changes: 1 addition & 34 deletions src/scene_game.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class Player {
// if(this.acc_y<0)
// renderRect(this.x,this.y+this.h,this.w,10,'yellow')
const frame = Math.floor(game.ticks.frame/sprites[game.npc.type].slowness)
ctx.drawImage(sprites.character.img,
ctx.drawImage(sprites.player.img,
GAME_CELL_SIZE*(frame%sprites[game.npc.type].frames),
this.acc_y<0 ? GAME_CELL_SIZE : 0,
GAME_CELL_SIZE,
Expand Down Expand Up @@ -285,39 +285,6 @@ function gameSceneLoop() {
}
}))
}
function renderNPCOdd() {
if(game.ticks.npc==0) {
game.npc_odd.type = ['screw','amp'][randomInt(2)]
game.npc_odd.pattern = structuredClone(game.patterns[game.npc_odd.type][randomInt(game.patterns[game.npc_odd.type].length)])
game.npc_odd.offset.x = randomInt(W/GAME_CELL_SIZE-game.npc_odd.pattern[0].length)
game.npc_odd.offset.y = randomInt(GAME_PADDING,H/GAME_CELL_SIZE-GAME_PADDING-game.npc_odd.pattern.length)
}
const frame = Math.floor(game.ticks.frame/sprites[game.npc_odd.type].slowness)
game.npc_odd.pattern.forEach((row,i) => row.forEach((cell,j) => {
if(cell) {
let npc_x = W*2-game.ticks.npc*GAME_SPEED_H+(game.npc_odd.offset.x+j)*GAME_CELL_SIZE
let npc_y = (game.npc_odd.offset.y+i)*GAME_CELL_SIZE
ctx.drawImage(
sprites[game.npc_odd.type].img,
GAME_CELL_SIZE*(frame%sprites[game.npc_odd.type].frames),0,GAME_CELL_SIZE,GAME_CELL_SIZE,
npc_x,npc_y,GAME_CELL_SIZE,GAME_CELL_SIZE
)
if(checkIntersection2D(
player.x,player.y,player.w,player.h,
npc_x,npc_y,GAME_CELL_SIZE,GAME_CELL_SIZE
)) {
if(game.npc_odd.type=='screw') {
game.score++
game.npc_odd.pattern[i][j] = 0
soundPlay('screw')
}
if(game.npc_odd.type=='amp')
if(game.state=='running')
gameChangeState('lose')
}
}
}))
}
function renderLoseScreen() {
renderRect(
W/2*(1-GAME_LOSESCREEN_SIZE),
Expand Down

0 comments on commit 47d8227

Please sign in to comment.