This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

KalleLarsson
KalleLarsson presents ...

2014/8/12

theGame-A functionality demo

This game is a basis for a high quality -jump-run-and shoot scrolling platformer. The levels are not that
fun but are mainly a demonstration of the functionality I've implemented.
(Remember to sprint for a looong jump on the second level...)

********** WALL OF TEXT FOR THE INTERESTED***JUST SCROLL DOWN TO PLAY************
A scrolling platformer game I made as an assingment for a programming course. Theres also a simple level editor class implemented that allows you to draw levels as a Picture and then "scan" them into the world.
This game is mostly a demo of the core functionality I wanted to implement, and please feel free to use my code to make your own games, but if you do, please notify me as I would like to know if someone makes something cool and inspiring, Mail: karlars [at]live.se

I apologize in advance that the levels are quite hard and not that fun to play, but I really ran out of imagination Before the deadline of this project. I might add some funnier levels later, since it's quite easy to do :) but first I have work and exams to attend...

The scrolling functionality should be pretty simple to lift right out, only copy the superclass ScrollingObjects and have all your object extend this one, and also have the method drawMe() in all the objects act methods. And also remember that no scrolling will occur if the camera is not moved. In this example the Player have a method, updateCam(), to move the cam, when needed.

The dynamic movement with inertia etc is also implemented in a superclass, MovingObjects, that can be lifted right out to obtain smooth movement with a nice feeling. Just remember that the dynamic movement is obtained by calling accelerate(), which uses the force-Vector every MovingObject has to obtain a new velocity. So manipulate your objects by adding forces to this vector in their Act methods.

The HUD or (Health and stamina bars) can also be lifted right out, and is updated by just removing the whole thing and adding a new one every Act.
Note that the interpolation for the Health bar is in the "growing direction" and the stamina bar in the "decreasing direction", so you have nice examples of how to implement both.

The level- editor functionality is essentially just a image scanner that looks for rectangles (representing platforms and their size, (All my platforms can have arbitrary size, with automatic tiling of the texture if they become very large), the color of the rectangle determines the type) or single pixels (which represents an instance of an object placed at this point.)
In the method getLevel() objects are created as a function of which color we find, and just change wich type of object you want built instead to be able to add your own objcets. The Objcets are then stored in a list of ActorDecriptions, which essentially says which object it is, and where in the World it should be added.
To understand how the editor class work, please study the source code and also look at the images named "level2.png" and "level3.png" to see the implementation. Keep in mind that objects that are not platforms are represented by a single pixel so they can be hard to see if you don't zoom in,

4293 views / 1152 in the last 7 days

3 votes | 0 in the last 7 days

Tags: game physics demo with-source scrolling platformer editor ijsk14 parallax

open in greenfoot
Your browser is ignoring the <APPLET> tag.
KalleLarssonKalleLarsson

2014/8/12

If you cant see the whole game area, just zoom in via your browser settings, or just download the game.
lordhersheylordhershey

2014/8/12

I will have to take a peek at the level editor.
KalleLarssonKalleLarsson

2014/8/12

do that, and if you have any questions, just let me know. :)
roonie01roonie01

2017/12/16

why dose it not work even when I choose update the code
Super_HippoSuper_Hippo

2017/12/16

Update code means that it will remove the imports of the java.awt.Color and .Font. You have to update the code which is underlined in red then if the code was written differently (like lowercase for colors or constructors which aren't working anymore, especially for fonts).

Want to leave a comment? You must first log in.

Who likes this?

winnerpig Artyoum lordhershey