diff --git a/README b/README index 8fe48b5..b802316 100644 --- a/README +++ b/README @@ -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. diff --git a/res/background.pdn b/res/background.pdn index eeb8300..82f14ca 100644 Binary files a/res/background.pdn and b/res/background.pdn differ diff --git a/res/background.png b/res/background.png index 002eef6..860a5ee 100644 Binary files a/res/background.png and b/res/background.png differ diff --git a/res/clouds.png b/res/clouds.png index fc828fb..8d0f3ad 100644 Binary files a/res/clouds.png and b/res/clouds.png differ diff --git a/res/character.pdn b/res/player.pdn similarity index 100% rename from res/character.pdn rename to res/player.pdn diff --git a/res/character.png b/res/player.png similarity index 100% rename from res/character.png rename to res/player.png diff --git a/src/assets.js b/src/assets.js index 165bc85..ce853d1 100644 --- a/src/assets.js +++ b/src/assets.js @@ -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}, @@ -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}, diff --git a/src/inputs.js b/src/inputs.js index 1487d71..7f5debd 100644 --- a/src/inputs.js +++ b/src/inputs.js @@ -2,7 +2,8 @@ loadResources() /* After page loaded */ -addEventListener('load',() => { +if(MOBILE) alert('Game not available on mobile devices') +else addEventListener('load',() => { mainInit() mainLoop() diff --git a/src/scene_game.js b/src/scene_game.js index 514a13f..f654646 100644 --- a/src/scene_game.js +++ b/src/scene_game.js @@ -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, @@ -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),