-
Notifications
You must be signed in to change notification settings - Fork 2
Level creator #26
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
Open
FCO
wants to merge
19
commits into
master
Choose a base branch
from
level_creator
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Level creator #26
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
e0b700c
WiP: separete file for block
FCO 3e2be8e
Preload block and get it by symbol
FCO c009ba5
If symbol wasnt found, use the regular block and the symbol as color
FCO bedb0a1
Fix block color for non safari browsers
FCO b697871
WiP: reading level file
FCO e2c586e
WiP: reading level file
FCO b3c301d
WiP: Remove ghost
FCO 5312907
Read multiple levels from lvl files
FCO 7fe8089
add dependency
FCO b03389d
untrack levels.js file
FCO 3300318
Improve scripts compatibility
pedrohml 0ff7742
Improve file organization
pedrohml 50bbdc9
Gulp initial usage to generate brickbreaker js levels
pedrohml 724ec50
Move brickbreaker tasks to right directory
pedrohml e9cc510
WiP: playing with gulp
FCO cf96a81
Fix gulp changes
FCO 9a2b893
Using module concept on gulpfiles
FCO e68e939
Merge
FCO df5d09e
Fix old bug
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| var Screen = require(".."); | ||
| require("./brick_breaker_blocks/regularBlock.js"); | ||
|
|
||
| var screen = new Screen(document.body); | ||
| screen.has_gravity(0, 10); | ||
| screen.color = "#FFFFFF"; | ||
|
|
@@ -32,15 +34,31 @@ create_lives(); | |
| var quad = screen.createElement("Poligon"); | ||
| var bola = screen.createElement("Arc"); | ||
|
|
||
| require("./brick_breaker_blocks/regularBlock.js"); | ||
|
|
||
| var blocks = {}; | ||
| [ | ||
| "regularBlock" | ||
| ].forEach(function(block) { | ||
| var conf = require("./brick_breaker_blocks/" + block + ".js"); | ||
| blocks[conf.symbol] = conf; | ||
| }); | ||
| function Blocks(files) { | ||
| this.blocks = {}; | ||
| files.forEach(function(block) { | ||
| var conf = require("./brick_breaker_blocks/" + block + ".js"); | ||
| this.blocks[conf.symbol] = conf; | ||
| }.bind(this)); | ||
|
|
||
| } | ||
| Blocks.prototype = { | ||
| get: function (symbol) { | ||
| var block_conf, pars = {}; | ||
| if(symbol in this.blocks) { | ||
| block_conf = this.blocks[symbol]; | ||
| } else { | ||
| block_conf = this.blocks["###"]; | ||
| pars.color = symbol; | ||
| } | ||
| var block = screen.createElement(block_conf.type); | ||
| block_conf.transformation.call(block, pars); | ||
| return block; | ||
| } | ||
| }; | ||
|
|
||
| var blocks = new Blocks(["regularBlock"]); | ||
|
|
||
| levels.starter = function () { | ||
| quad.destroy(); | ||
|
|
@@ -161,9 +179,8 @@ levels.add_level(function () { | |
| var blocks_space = 5; | ||
| var r = w - (number_of_blocks * block_size + (number_of_blocks - 1) * blocks_space); | ||
| for(var i = r / 2; i < w - (r / 2); i += block_size + blocks_space) { | ||
| var block_conf = blocks["###"]; | ||
| block_counter++; | ||
| var block = screen.createElement(block_conf.type); | ||
| block = blocks.get("0f0"); | ||
| block.randomPowerUp = randomPowerUp; | ||
| block.on_destroy = function() { | ||
| block_counter--; | ||
|
|
@@ -183,7 +200,6 @@ levels.add_level(function () { | |
| block.going2destroy = going2destroy; | ||
| block.x = i + block_size / 2; | ||
| block.y = 120 + j * 30; | ||
| block_conf.transformation.call(block); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -192,18 +208,18 @@ levels.add_level(function () { | |
| if(Math.random() <= powerUpPercentage){ | ||
| // TODO: Create a Power Up factory and multiple types of power ups to randomize | ||
| var powerup = screen.createElement("Poligon"); | ||
| powerup.visible = true; | ||
| powerup.color = "#4EA132"; | ||
| powerup.draw_colition_area = false | ||
| powerup.do_not_colide_with = ["Block"]; | ||
| powerup.bounce_when_colide_with = ["Border"]; | ||
| powerup.type = "PowerUp"; | ||
| powerup.x = this.x | ||
| powerup.y = this.y; | ||
| powerup.flutuate = false; | ||
| powerup.velocity = velocity.clone(); | ||
| powerup.velocity.mod *= 0.3; | ||
| powerup.velocity.ang *= -1; | ||
| powerup.visible = true; | ||
| powerup.color = "#4EA132"; | ||
| powerup.draw_colition_area = false | ||
| powerup.do_not_colide_with = ["Block"]; | ||
| powerup.bounce_when_colide_with = ["Border"]; | ||
| powerup.type = "PowerUp"; | ||
| powerup.x = this.x | ||
| powerup.y = this.y; | ||
| powerup.flutuate = false; | ||
| powerup.velocity = velocity.clone(); | ||
|
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. identação |
||
| powerup.velocity.mod *= 0.3; | ||
| powerup.velocity.ang *= -1; | ||
|
|
||
| powerup.add_vertice(0, 0); | ||
| powerup.add_vertice(7, 14); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
identação