HTML and CSS Reference
In-Depth Information
function
function
canvasApp
(){
var
var
theCanvas
=
document
.
getElementById
(
"canvas"
);
iif
(
!
theCanvas
|| !
theCanvas
.
getContext
) {
return
return
;
}
var
var
context
=
theCanvas
.
getContext
(
"2d"
);
iif
(
!
context
) {
return
return
;
}
//application states
const
const
GAME_STATE_TITLE
=
0
;
const
const
GAME_STATE_NEW_LEVEL
=
1
;
const
const
GAME_STATE_GAME_OVER
=
2
;
var
var
currentGameState
=
0
;
var
var
currentGameStateFunction
=
null
null
;
function
function
switchGameState
(
newState
) {
currentGameState
=
newState
;
switch
switch
(
currentGameState
) {
case
case
GAME_STATE_TITLE
:
currentGameStateFunction
=
gameStateTitle
;
break
break
;
case
case
GAME_STATE_PLAY_LEVEL
:
currentGameStateFunctionappStatePlayeLevel
;
break
break
;
case
case
GAME_STATE_GAME_OVER
:
currentGameStateFunction
=
gameStateGameOver
;
break
break
;
}
}
function
function
gameStateTitle
() {
ConsoleLog
.
log
(
"appStateTitle"
);
// draw background and text