-
Notifications
You must be signed in to change notification settings - Fork 157
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
Added a prototype for Level #117
Changes from 2 commits
2ac448f
5caf4fd
450a72a
40de265
56b349f
a6d2da1
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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
function Level(home, backgroundLayers, obstaclesLayer){ | ||
this._backgrounds = backgroundLayers; | ||
this.obstacleLayer = obstaclesLayer; | ||
this._obstacles = createObstacles(obstaclesLayer); | ||
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. What does this line do? |
||
this._name = name; | ||
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. where does name com from? |
||
this._score = 0; | ||
} | ||
|
||
Level.prototype = { | ||
|
||
show: function(){ | ||
show_layer(this.obstaclesLayer); | ||
for (layer in this.backgrounds){ | ||
show_layer(layer); | ||
} | ||
}, | ||
|
||
hide: function(){ | ||
hide_layer(this.obstaclesLayer); | ||
for (layer in this.backgrounds){ | ||
hide_layer(layer); | ||
} | ||
}, | ||
|
||
getBackgrounds(): function(){ | ||
return this._backgrounds; | ||
}, | ||
|
||
getObstacles: function(){ | ||
return this._obstacles; | ||
}, | ||
|
||
getName(): function(){ | ||
return this._name; | ||
}, | ||
|
||
getScore(): function{ | ||
return this_score; | ||
}, | ||
|
||
start(): function(){ | ||
//Needs to be Implemented | ||
}, | ||
|
||
stop(): function(){ | ||
// Needs to be Implemented | ||
}, | ||
|
||
} | ||
|
||
var all_levels,current_level; | ||
|
||
function getAllLevels(){ | ||
return all_levels; | ||
} | ||
|
||
function newLevel(name,backgroundLayers,obstaclesLayer){ | ||
return new Level(name,backgroundLayers,obstaclesLayer); | ||
} | ||
|
||
function AlllevelObjects(){ | ||
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. Should this be executed several times? Can you remove this function and make the spec a global variable? 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. Everytime you start a game this function should be executed. 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. I expect getAllLevels to return the same levels all the time. There are several ways to meet this expectation, which I see:
What is your perspective on this? |
||
// Need to be properly Modified | ||
levels = ["level1","level2"]; | ||
|
||
backgrounds = { | ||
"level1":[], | ||
"level2":[] | ||
}; | ||
|
||
obstacles = { | ||
"level1":"obstacle for level1", | ||
"level2":"obstacle for level2", | ||
}; | ||
|
||
for(level in levels){ | ||
all_levels[level] = newLevel(level,backgrounds[level],obstacles[level]); | ||
} | ||
} | ||
|
||
function setCurrentLevel(name){ | ||
current_level = all_levels[name]; | ||
} | ||
|
||
function getCurrentLevel(){ | ||
return current_level; | ||
} |
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.
I think, we can have several obstacle layers