This repository was archived by the owner on May 1, 2024. It is now read-only.
Open
Conversation
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Whilst waiting for @ketanhwr to merge #55 written by @KenyStev , i am just adding this class constructor based on the level JSON object definition in that pull request. this is for ease of use as well as a possible future live screen level creation.
here are the instructions for use, which are also available in the .js file:
To create a new level, type
let <levelname> = new GameLevel(<enemy ship x-coordinate>, <enemy ship y-coordinate>, <spacestation x-coordinate>, <spacestation y-coordinatie>).To add mirrors, type
<levelname>.addMirror(<x-coordinate><y-coordinate>, <width>, <height>);. If you want the mirrors position to be fixed, add"fixed"ortruein the parameters after the height. Default width/height is 100.For circular mirrors, use the same function but leave out the width and height (add
"fixed"after the y-coordinate instead).To add an asteroid, a moving asteroid, or another spacestation, the methods are
.addAsteroid,.addMovingAsteroid, and.addSpacestationrespectively, with the X- and Y- coordinates included as arguments.Any of these methods can also be called in bulk by putting multiple sets of arguments in brackets.
As an example, here is how level one could be written out. i wrote out the mirrors and asteroids one-by-one for the example, but they could be written in bulk, as shown in examples of levels nine and ten below.
let one = new GameLevel(width-140, 100, midx-70, 100); one.addMirror(200, 150); one.addMirror(600, 400, 100, -100); one.addAsteroid(1000, 100); one.addAsteroid(1000, 200); one.addAsteroid(1100, 240);let nine = new GameLevel(-15, 520, 13, 90); nine.addSpacestation(1067, 90); nine.addAsteroid([95, 545], [105, 465], [37, 430]); nine.addMirror([350, 520, 17, 80], [1040, 320, -100, -80], [910, 480, 100, -50], [250, 170, 47.8, -100]);let ten = new GameLevel(width-90, 250, midx+370, 200) ten.addSpacestation(370, 100); ten.addMirror([380, 520], [600, 400, 100, 0]); ten.addCircMirror(200, 300); ten.addAsteroid([900, 1], [900, 50], [900, 150], [900, 250], [900, 350], [1090, 170], [1095, 350], [1150, 390]);levelsDefinition.push(one, nine, ten)also included is a console log of the object for the first level of the game built as above
