HW3 -- Physics with Sugared Box2D
0. | This HW is a varation of previous HW or hackathons from other iteration of this class, we will supply hints from these classes below. The crate & vine code that you downloaded was contributed from previous students (vine from one student, crates from another) of these iteration, and has been converted into the dorm scenario from the textbook. Use the crate.zip package discussed in class from the class site, it is a standalone version of Box2D with Sugared Box2D already installed (makes it work better with impactJS). The code is not perfect. [can't reference the URL here publically since it is not baked, making impactJS available]. Edit main.js and make sure that it includes the proper Box2D plug-in by editing the body of .requires(), i.e., in .requires(), add the string : "joncom" as follows: 'plugins.joncom.box2d.game', Now load the game and play with player and crate, look at entity player, and look at entity crate and read the code. In the code of player(), that it uses Force vectors to effect the movement of the player, instead of directly manipulating physics by velocity, and accelerating variables. Look at the references and resources (here are a few). http://impactjs.com/documentation/physics-with-box2d http://www.box2dflash.org/docs/2.1a/reference/ http://box2d.org/documentation.html Rope forum discussion:
|
Create a game using an environment similar to the dorm set up above with an upper hallway, and larger area to the right. Set up several crates in the narrow area. Set up at leat two 'straight' vines on the larger area that are not reachable to the player. Task 1: Enable the player to swing on one vine by reaching the vine from standing on a crate. Task 2: Enable the player so that once he is on the vine he can climb up the vine without falling off, using the ARROW up key (consider doing this task last), and down the vine using the ARROW down key. Task 3 : Enable jumping off the vine by the 'jump' (X) key, i.e., the player should be released from the vine and fall to the floor. Task 4: Enable 3 but with the (Z) key and here the player maintains his momentum while jumping off. Task 5: Enable the player to swing from one vine onto another.
|
|
Hints in general: UP to you to figure out if these 'hints' are useful or not, and what they do. HINT 1: For Swinging, read the hint further below. HINT 2 : 2 Code Snippets: HINT 3: reset the swingTimer.reset(); when the player 'jumps' off |
|
HINT 1 (more details: from student of a previous class) Regarding the swinging in Box2D. The student who originally contributed the vine code recommends that you need to an additional declaration in player.js. contactBox: null, This will allow you to utilize positional attributes such as GetPosition() and GetAngle(). GetAngle() you may need to get the drawing to line up properly. ContactBox is originally set in vine.js - See line 125 (or nearby) in vine.js (already existing). Example functions you can NOW use in player.js after declaring: contactBox: null, var velocity = this.contactBox.GetLinearVelocity(); // maintaining momentum while jumping off box. |
|
Submission:
Submit all code to nike and it must include all code, i.e., box2d and the ImpactJS engines
Please submit your work on nike.cs.uga.
submit HW3-Box2D csx070