Platformer Java Guide by Mr. Monroe.

Slides:



Advertisements
Similar presentations
Games and Simulations O-O Programming in Java The Walker School
Advertisements

Program: Little Crab Mr Gano.
Code Club Session 3 Shark Eats Fish. Picture of finished product here.
Games and Simulations O-O Programming in Java The Walker School
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
In.  This presentation will only make sense if you view it in presentation mode (hit F5). If you don’t do that there will be multiple slides that are.
Introduction to TouchDevelop
Click your mouse for next slide Flash – Introduction and Startup Many times on websites you will see animations of various sorts Many of these are created.
VIDEO GAME PROGRAMMING Video Game Programming Junior – DigiPutt INSTRUCTOR TEACHER’S ASSISTANT.
Spreadsheets in Finance and Forecasting Presentation 9 Macros.
GAME:IT Helicopter Objectives: Review skills in making directional sprites Create objects that shoot and destroy for points Create random enemies on the.
Game Maker Terminology
Advanced Stuff Learning by example: Responding to the mouse.
Lesson 3: Arrays and Loops. Arrays Arrays are like collections of variables Picture mailboxes all lined up in a row, or storage holes in a shelf – You.
Lesson 2: Reading a program. Remember: from yesterday We learned about… Precise language is needed to program Actors and Classes Methods – step by step.
GAME:IT Mario Creating Platform Games Level 4 with GML Game Maker Language (GML) allows users more flexibility in game design. GML is similar to how real.
The Stingray Example Program CMT3311. Stingray - an example 2D game May be useful as a simple case study Most 2D games need to solve generic problems.
CompSci 4 Java 4 Apr 14, 2009 Prof. Susan Rodger.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
Perform a complete mail merge Lesson 14 By the end of this lesson you will be able to complete the following: Use the Mail Merge Wizard to perform a basic.
Index Background Costumes Making object walk smoothly Controlling an object with the keyboard Control an object with the mouse Changing costume when hit.
Chapter 11: Scrolling with Greenfooot. What Is Scrolling? Scrolling is an important and often necessary concept in games. It can be used to: a)Convey.
Sound and more Animations
Chapter 4 - Finishing the Crab Game
Modifying GridWorld Classes.
MOM! Phineas and Ferb are … Aims:
Intro CS – Screens and Variables
Scratch for Interactivity
An Introduction to Alice (Short Version)
Exploring Mathematical Relationships Module 5: Investigation 3
Today's Challenge: More Animation Storytelling and Scrolling!
Classwork: Examine and enhance falling drop(s) or make your own.
Background Shapes & Collision Resolution (Top-down and Side-scrolling)
Chapter 3 – Improving the Crab Game
Android 11: The Calculator Assignment
An Introduction to Spritesheet Animation
Using Procedures and Exception Handling
Programming – Touch Sensors
Absolute Value and Comparing Rational Numbers
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Project Snake. Project Snake Snake For this project, we’re going to make Snake This includes Making the overall game logic (using a 2D array) Handling.
Scratch Programming Intro
Learning Objective LO: We’re learning to understand when it is appropriate to use particular data types.
Version 2.
File Handling Programming Guides.
FORCES & THEIR EFFECTS In This Topic We Will Learn About:
Organizing Memory in Java
“Day C” November 28, :01 - 9:01 Math 9: :03 Science
“Day B” November 29, :51 - 8:51 Exploratory 8:53 - 9:53
Physics of Basketball By: Maya Zee.
Go to =>
Tank Game Part 6 of 6.
Coding Concepts (Basics)
Introduction to TouchDevelop
Programming games Classes and objects (used for Jigsaw, Bouncing stuff, other projects) Homework: Complete cannonball. Video or Audio. Your own project.
An Introduction to Alice
Game Loop Update & Draw.
Lesson 3.2 Review: Identifying concepts
Developing Sentence Skills
Problem Solving Designing Algorithms.
Collision Detection Platforms.
Lecture 7: Introduction to Processing
“Day E” November 19, :51 - 8:51 Math 8:53 - 9:53 Science
Game Maker Intro to Programming Game Maker Pop Quiz (Both Groups)
Running a Java Program using Blue Jay.
Chapter 1 Introducing Small Basic
Java Lessons Mr. Kalmes.
Chapter 9 Using Decisions to
Work.
Developing Sentence Skills
Presentation transcript:

Platformer Java Guide by Mr. Monroe

Step 1: Setup Make a new Greenfoot Java scenario and copy the following images from the work drive into your scenario’s images folder:

Create the following classes  Step 2: World & Actors Create the following classes  The MyWorld class will extend Scrolling to allow the screen to move. The code for Scrolling can be found on the work drive. It’s a little complex! All blocks can extend a Obstacle and all enemies can extend Goomba instead of extending Actor.

Step 3: Scrolling code This code is on the work drive for you to copy and paste! It works via setLocation!

Step 4: MyWorld code This class will extend Scrolling and currently sets up a 1000x800 world with Mario and some floor blocks!

Step 5: Obstacle and Blocks These classes don’t need much code! Make Obstacle an abstract class with no image. Then, make Block1 and Block2 extend Obstacle!

Step 6: Mario’s Variables Mario needs a lot of variables to keep track of what he is up to! He’s got a ton of images, how much to scale them by, horizontal and vertical speeds, timers for frames and animations, and booleans for different states!

Step 7: Mario’s Constructor Mario’s constructor needs to assign and scale all of his images. Make sure that you type in the names of all of the PNG pictures correctly or you will get a “FileNotFound” error!

Step 8: Mario’s Scale Method Mario needs a scale method so that he can scale his images to be larger based on the “scaleAmount” variable. Right now, it is assigned the value 3, which means that all of his images will appear three times bigger than they were drawn.

Step 9: Mario’s Act Method Mario’s act method has a ton of necessary code segments: Figure out if Mario is on the ground. Move him based on gravity and key presses. Cap his speed to some limit. Apply friction if no keys are pressed. Update his location. Change his picture to the correct one. Fix his location if it is colliding with something. Respawn if Mario fell or touched enemy.

Step 9.1: onGroundCheck The first thing we need to do is figure out if Mario is on the ground. This will determine if he is allowed to jump! This code can either be in a method called onGroundCheck or just placed at the beginning of the act method:

Step 9.2: Gravity and Key Presses The second thing we need to do is apply gravity by increasing Mario’s ySpeed by one. Next, let’s do the A and D key presses! Fill in the blanks and comments with the appropriate code!

Step 9.2: Gravity and Key Presses Now, let’s do the W key for jumping! Try picking numbers to find a good jump height! Fill in the blanks with the appropriate code!

Step 9.3: Speed Limit Mario shouldn’t be able to run or fall at an unlimited speed. That could lead to some problems, like him becoming Sonic! Try picking numbers and trying it out! Fill in the blanks with the appropriate code!

Step 9.4: Friction Mario’s horizontal speed should slow down due to “friction” or “air resistance”. One way of doing this is shown below, where Mario’s xSpeed gets closer to zero every other frame. If you use this technique, make sure you have frame++; written at the beginning of your act method!

Step 9.5: Update Location Now that we are done with gravity, key presses, limits, and friction, let’s update Mario’s position for the next frame! This could set him half-way inside of a block, but we will fix it later by doing some collision checking in the last step!

Step 9.6: Animation Set Mario’s image based on his current state! See if you can read the code to figure out which image to use!

Step 9.6: Animation Set Mario’s image based on his current state! See if you can read the code to figure out which image to use!

Step 9.7: Collision Our last step is to call a collision method to fix Mario’s position if he is touching a obstacle! This method checks these eight points to determine if Mario is colliding with an obstacle 

public static RespawnPoint rp; rp = new RespawnPoint(); Step 9.8: Respawn Before we add the separate method to handle collisions, let’s create a respawn mechanic. Create a new Actor called RespawnPoint with no additional code or image assigned to it. Then, add the following to MyWorld: public static RespawnPoint rp; and in the world’s constructor: rp = new RespawnPoint(); addObject(rp, 500, 400); and finally, in Mario’s act method: if(getY() > 800) { setLocation(MyWorld.rp.getX(), MyWorld.rp.getY()); } Then, try jumping off of your platform and see if you respawn!

Step 10.1: Collision Method For the collision method, we first need to figure out if an obstacle exists at one of the eight points! Fill in the blanks with the correct offset values!

Step 10.2: Collision Method Then, we need to set Mario’s X or Y speed to zero and move him out of the block he is colliding with! I will give you BL, BR, RB, RT, but you must write four more if-statements to complete all the collisions!

Can you program a Goomba AI? Step 11: Goomba Enemies! Can you program a Goomba AI? Hints: The Goomba code will reuse some of Mario’s code, such as setting the images up and scaling them. They will also have gravity, setLocation, and the collision method! Switch them between pictures 1 and 2 every 12 frames. Finally, make them walk left and flip the direction when BR or BL is null or bump into something!