-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature fun #2
base: development
Are you sure you want to change the base?
Feature fun #2
Changes from 1 commit
1b13fdb
cac9e33
10e8eb5
1167937
6856319
54d6158
246baef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,13 @@ var pauseInst = new Text('pauseInst',app.width/2 + (secondText/2), app.height - | |
|
||
var state = 'START' | ||
|
||
/** | ||
* Add Game Music Level1.wav | ||
* Created by https://juhanijunkala.com/ | ||
*/ | ||
var music = new Sound('sounds/level1.wav', true) | ||
|
||
// Init | ||
app.onInit = function(){ | ||
|
||
document.addEventListener('keydown', (event) => { | ||
|
@@ -54,13 +61,16 @@ app.onInit = function(){ | |
PlayerTwo.moveDown(false) | ||
|
||
if(keyName == 'Enter'){ | ||
if(state == 'START') | ||
if(state == 'START'){ | ||
music.play() // Start Game Music | ||
state = 'GAME' | ||
} | ||
} | ||
|
||
if(keyName == ' '){ | ||
if(state == 'GAME' || state == 'PAUSE') | ||
if(state == 'GAME' || state == 'PAUSE'){ | ||
this.pause() | ||
} | ||
} | ||
|
||
if(keyName == 'r'){ | ||
|
@@ -90,11 +100,13 @@ app.onUpdate = function(time){ | |
|
||
app.pause = function(){ | ||
if(state == 'GAME'){ | ||
music.pause() // Pause Game Music | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, yes I define the "music" object and added some comments when I invoke the methods |
||
state = 'PAUSE' | ||
pauseText.setText("Pause") | ||
pauseInst.setText("press 'R' for reset") | ||
} | ||
else{ | ||
music.play() // Resume Game Music | ||
state = 'GAME' | ||
pauseText.setText("") | ||
pauseInst.setText("") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a typo and the game breaks
maybe you shouldn't use strings huh?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know how to use enum?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, I haven´t use enum before but I can change it and not use strings