Prototype of platform game

try my three levels simple platform game
http://goldenstudios.uni.cc/contents/products/games/bin/platform.jnlp
any bugs?
thank you

Ran fine. You should have some sort of loading screen in the beginning though.

Similar Messages

  • Error #1009 in my Platform Game! Please Help!!!

    In my basic platform game I have a "hero" that can walk and jump on the "ground." There is also a door to the next scene, which is the next level.The first scene works fine, but "TypeError: Error #1006: value is not a function. at Charles3_fla::MainTimeline/frame1()" pops up once in the output. It works however, and I'm not worried about it. The second I go throught the door though, Scene 2 opens, but then starts flashing as "TypeError: Error #1009: Cannot access a property or method of a null object reference. at Charles3_fla::MainTimeline/onenter()" pops up A LOT in the output. I don't know how to fix it, and would like help. P.S. I am using Adobe CS5 with actionscript 3
    Here is the code for Scene 1:
    hero.gotoAndStop('still');
    var Key:KeyObject = new KeyObject(stage);
    var vy:Number=0;
    var gravity:Number=2;
    var jumped:Boolean = false;
    stage.addEventListener(Event.ENTER_FRAME,onenter)(true);
    function onenter(e:Event):void{
    vy+=gravity;
    if(! ground.hitTestPoint(hero.x,hero.y,true)) {
      hero.y+vy;
    if(ground.hitTestPoint(hero.x+(hero.width/2), hero.y-(hero.height/2), true)) {
      hero.x-=13;
    if(ground.hitTestPoint(hero.x-(hero.width/2), hero.y-(hero.height/2), true)) {
      hero.x+=13;
    if (vy>10) {
      vy=10;
    for (var i:int = 0; i<10; i++) {
      if (ground.hitTestPoint(hero.x,hero.y,true)) {
       hero.y--;
       vy=6;
       jumped=true;
    if(door.hitTestObject(hero)){
        gotoAndPlay(1,"Scene 2");
    if(hero.y>300){
      vy=6;
      jumped=true;
      if(Key.isDown(Key.UP) && jumped){
       vy=-13;
       jumped=false;
       hero.y+=vy;
    if(Key.isDown(Key.RIGHT)){
      hero.x+=10;
      hero.scaleX=1;
      hero.gotoAndStop('walking');
      }else if(Key.isDown(Key.LEFT)){
      hero.x-=10;
      hero.scaleX=-1;
      hero.gotoAndStop('walking');
      }else{
       hero.gotoAndStop('still');
    And for Scene 2...
    hero.gotoAndStop('still');
    var Key1:KeyObject =KeyObject(stage);
    var vy1:Number=0;
    var gravity1:Number=2;
    var jumped1:Boolean = false;
    stage.addEventListener(Event.ENTER_FRAME,onenter1)(true);
    function onenter1(e:Event):void{
    vy1+=gravity;
    if(! ground.hitTestPoint(hero.x,hero.y,true)) {
      hero.y+vy;
    if(ground.hitTestPoint(hero.x+(hero.width/2), hero.y-(hero.height/2), true)) {
      hero.x-=13;
    if(ground.hitTestPoint(hero.x-(hero.width/2), hero.y-(hero.height/2), true)) {
      hero.x+=13;
    if (vy1>10) {
      vy1=10;
    for (var i:int = 0; i<10; i++) {
      if (ground.hitTestPoint(hero.x,hero.y,true)) {
       hero.y--;
       vy1=6;
       jumped1=true;
    if(door.hitTestObject(hero)){
        gotoAndPlay(1,"Scene 2");
    if(hero.y>300){
      vy1=6;
      jumped1=true;
      if(Key.isDown(Key.UP) && jumped1){
       vy1=-13;
       jumped1=false;
       hero.y+=vy;
    if(Key.isDown(Key.RIGHT)){
      hero.x+=10;
      hero.scaleX=1;
      hero.gotoAndStop('walking');
      }else if(Key.isDown(Key.LEFT)){
      hero.x-=10;
      hero.scaleX=-1;
      hero.gotoAndStop('walking');
      }else{
       hero.gotoAndStop('still');
    Please reply as soon as possible, and thanks for your time
    swiatekalex555

    Ok sorry about my misunderstanding. Here's the code with the errors Highlighted. I also downloaded a "KeyObject.as" package, and the contents of that are on the bottom.
    hero.gotoAndStop('still');
    var Key:KeyObject = new KeyObject(stage);
    var vy:Number=0;
    var gravity:Number=2;
    var jumped:Boolean = false;
    stage.addEventListener(Event.ENTER_FRAME,onenter)(true);
    function onenter(e:Event):void{
    vy+=gravity;
    if(! ground.hitTestPoint(hero.x,hero.y,true)) {
      hero.y+vy;
    if(ground.hitTestPoint(hero.x+(hero.width/2), hero.y-(hero.height/2), true)) {
      hero.x-=13;
    if(ground.hitTestPoint(hero.x-(hero.width/2), hero.y-(hero.height/2), true)) {
      hero.x+=13;
    if (vy>10) {
      vy=10;
    for (var i:int = 0; i<10; i++) {
      if (ground.hitTestPoint(hero.x,hero.y,true)) {
       hero.y--;
       vy=6;
       jumped=true;
    if(door.hitTestObject(hero)){
        gotoAndPlay(1,"Scene 2");
    if(hero.y>300){
      vy=6;
      jumped=true;
      if(Key.isDown(Key.UP) && jumped){
       vy=-13;
       jumped=false;
       hero.y+=vy;
    if(Key.isDown(Key.RIGHT)){
      hero.x+=10;
      hero.scaleX=1;
      hero.gotoAndStop('walking');
      }else if(Key.isDown(Key.LEFT)){
      hero.x-=10;
      hero.scaleX=-1;
      hero.gotoAndStop('walking');
      }else{
       hero.gotoAndStop('still');
    And for Scene 2...
    hero.gotoAndStop('still');
    var Key1:KeyObject =KeyObject(stage);
    var vy1:Number=0;
    var gravity1:Number=2;
    var jumped1:Boolean = false;
    stage.addEventListener(Event.ENTER_FRAME,onenter1)(true);
    function onenter1(e:Event):void{
    vy1+=gravity;
    if(! ground.hitTestPoint(hero.x,hero.y,true)) {
      hero.y+vy;
    if(ground.hitTestPoint(hero.x+(hero.width/2), hero.y-(hero.height/2), true)) {
      hero.x-=13;
    if(ground.hitTestPoint(hero.x-(hero.width/2), hero.y-(hero.height/2), true)) {
      hero.x+=13;
    if (vy1>10) {
      vy1=10;
    for (var i:int = 0; i<10; i++) {
      if (ground.hitTestPoint(hero.x,hero.y,true)) {
       hero.y--;
       vy1=6;
       jumped1=true;
    if(door.hitTestObject(hero)){
        gotoAndPlay(1,"Scene 2");
    if(hero.y>300){
      vy1=6;
      jumped1=true;
      if(Key.isDown(Key.UP) && jumped1){
       vy1=-13;
       jumped1=false;
       hero.y+=vy;
    if(Key.isDown(Key.RIGHT)){
      hero.x+=10;
      hero.scaleX=1;
      hero.gotoAndStop('walking');
      }else if(Key.isDown(Key.LEFT)){
      hero.x-=10;
      hero.scaleX=-1;
      hero.gotoAndStop('walking');
      }else{
       hero.gotoAndStop('still');
    the KeyObject.as
    package {
    import flash.display.Stage;
    import flash.events.KeyboardEvent;
    import flash.ui.Keyboard;
    import flash.utils.Proxy;
    import flash.utils.flash_proxy;
      * The KeyObject class recreates functionality of
      * Key.isDown of ActionScript 1 and 2
      * Usage:
      * var key:KeyObject = new KeyObject(stage);
      * if (key.isDown(key.LEFT)) { ... }
    dynamic public class KeyObject extends Proxy {
      private static var stage:Stage;
      private static var keysDown:Object;
      public function KeyObject(stage:Stage) {
       construct(stage);
      public function construct(stage:Stage):void {
       KeyObject.stage = stage;
       keysDown = new Object();
       stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
       stage.addEventListener(KeyboardEvent.KEY_UP, keyReleased);
      flash_proxy override function getProperty(name:*):* {
       return (name in Keyboard) ? Keyboard[name] : -1;
      public function isDown(keyCode:uint):Boolean {
       return Boolean(keyCode in keysDown);
      public function deconstruct():void {
       stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
       stage.removeEventListener(KeyboardEvent.KEY_UP, keyReleased);
       keysDown = new Object();
       KeyObject.stage = null;
      private function keyPressed(evt:KeyboardEvent):void {
       keysDown[evt.keyCode] = true;
      private function keyReleased(evt:KeyboardEvent):void {
       delete keysDown[evt.keyCode];
    Help if you can,
    swiatekalex555

  • Help Please!!! AS3 Platform game

    I am creating a a platform game for one of my classes. I am not fimilar with Flash and I am having trouble with the coding. I keep getting this error message
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
        at TheBallMan2_fla::MainTimeline/frame4()
        at flash.display::MovieClip/gotoAndStop()
        at TheBallMan2_fla::MainTimeline/fl_ClickToGoToAndStopAtFrame_12()
    TheBallMan2 is the name I have my project saved as.
    My partner did all the coding but he doesn't really know what he is doing either. The character is supposed to move with the arrow keys which it did until we added the collision code. Here is our coding...which we got from following a tutorial online.
    /* Click to Go to Frame and Stop
    Clicking on the specified symbol instance moves the playhead to the specified frame in the timeline and stops the movie.
    Can be used on the main timeline or on movie clip timelines.
    Instructions:
    1. Replace the number 5 in the code below with the frame number you would like the playhead to move to when the symbol instance is clicked.
    About.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_3);
    function fl_ClickToGoToAndStopAtFrame_3(event:MouseEvent):void
        gotoAndStop(2);
    /* Click to Go to Frame and Stop
    Clicking on the specified symbol instance moves the playhead to the specified frame in the timeline and stops the movie.
    Can be used on the main timeline or on movie clip timelines.
    Instructions:
    1. Replace the number 5 in the code below with the frame number you would like the playhead to move to when the symbol instance is clicked.
    Help.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_4);
    function fl_ClickToGoToAndStopAtFrame_4(event:MouseEvent):void
        gotoAndStop(3);
    /* Click to Go to Frame and Stop
    Clicking on the specified symbol instance moves the playhead to the specified frame in the timeline and stops the movie.
    Can be used on the main timeline or on movie clip timelines.
    Instructions:
    1. Replace the number 5 in the code below with the frame number you would like the playhead to move to when the symbol instance is clicked.
    PlayButton.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_12);
    function fl_ClickToGoToAndStopAtFrame_12(event:MouseEvent):void
        gotoAndStop(4);
    /* Click to Go to Frame and Stop
    Clicking on the specified symbol instance moves the playhead to the specified frame in the timeline and stops the movie.
    Can be used on the main timeline or on movie clip timelines.
    Instructions:
    1. Replace the number 5 in the code below with the frame number you would like the playhead to move to when the symbol instance is clicked.
    if(Ground.hitTestPoint(Char.x + leftBumpPoint.x, Char.y + leftBumpPoint.y, true)){
        trace("leftBumping");
        leftBumping = true;
    } else {
        leftBumping = false;
    if(Ground.hitTestPoint(Char.x + rightBumpPoint.x, Char.y + rightBumpPoint.y, true)){
        trace("rightBumping");
        rightBumping = true;
    } else {
        rightBumping = false;
    if(Ground.hitTestPoint(Char.x + upBumpPoint.x, Char.y + upBumpPoint.y, true)){
        trace("upBumping");
        upBumping = true;
    } else {
        upBumping = false;
    if(Ground.hitTestPoint(Char.x + downBumpPoint.x, Char.y + downBumpPoint.y, true)){
        trace("downBumping");
        downBumping = true;
    } else {
        downBumping = false;
    var leftBumping:Boolean = false;
    var rightBumping:Boolean = false;
    var upBumping:Boolean = false;
    var downBumping:Boolean = false;
    var leftBumpPoint:Point = new Point(-30, -55);
    var rightBumpPoint:Point = new Point(30, -55);
    var upBumpPoint:Point = new Point(0, -120);
    var downBumpPoint:Point = new Point(0, 0);
    /* Move with Keyboard Arrows
    Allows the specified symbol instance to be moved with the keyboard arrows.
    Instructions:
    1. To increase or decrease the amount of movement, replace the number 5 below with the number of pixels you want the symbol instance to move with each key press.
    Note the number 5 appears four times in the code below.
    Char.addEventListener(Event.ENTER_FRAME, fl_MoveInDirectionOfKey_4);
    stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed_4);
    stage.addEventListener(KeyboardEvent.KEY_UP, fl_UnsetKeyPressed_4);
    function fl_MoveInDirectionOfKey_4(event:Event)
        if (upPressed)
            Char.y -= 0;
        if (downPressed)
            Char.y += 0;
        if (leftPressed)
            Char.x -= 0;
        if (rightPressed)
            Char.x += 0;
    function fl_SetKeyPressed_4(event:KeyboardEvent):void
        switch (event.keyCode)
            case Keyboard.UP:
                upPressed = true;
                break;
            case Keyboard.DOWN:
                downPressed = true;
                break;
            case Keyboard.LEFT:
                leftPressed = true;
                break;
            case Keyboard.RIGHT:
                rightPressed = true;
                break;
    function fl_UnsetKeyPressed_4(event:KeyboardEvent):void
        switch (event.keyCode)
            case Keyboard.UP:
                upPressed = false;
                break;
            case Keyboard.DOWN:
                downPressed = false;
                break;
            case Keyboard.LEFT:
                leftPressed = false;
                break;
            case Keyboard.RIGHT:
                rightPressed = false;
                break;
    var leftPressed:Boolean = false;
    var rightPressed:Boolean = false;
    var upPressed:Boolean = false;
    var downPressed:Boolean = false;
    var xScrollSpeed:int = 10;
    var yScrollSpeed:int = 10;
    function keyDownHandler(e:KeyboardEvent):void{
    if(e.keyCode == Keyboard.LEFT){
    leftPressed = true;
    } else if(e.keyCode == Keyboard.RIGHT){
    rightPressed = true;
    } else if(e.keyCode == Keyboard.UP){
    upPressed = true;
    } else if(e.keyCode == Keyboard.DOWN){
    downPressed = true;
    function keyUpHandler(e:KeyboardEvent):void{
    if(e.keyCode == Keyboard.LEFT){
    leftPressed = false;
    } else if(e.keyCode == Keyboard.RIGHT){
    rightPressed = false;
    } else if(e.keyCode == Keyboard.UP){
    upPressed = false;
    } else if(e.keyCode == Keyboard.DOWN){
    downPressed = false;
    stage.addEventListener(Event.ENTER_FRAME, loop);
    var scrollX:int = 0;
    var scrollY:int = 0;
    var ySpeed:int = 0;
    var xSpeed:int = 0;
    var speedConstant:int = 5;
    var friction:Number = 0.95;
    function loop(e:Event):void{
        if(leftPressed){
            xSpeed -= speedConstant;
        } else if(rightPressed){
            xSpeed += speedConstant;
        if(upPressed){
            ySpeed -= speedConstant;
        } else if(downPressed){
            ySpeed += speedConstant;
    if(leftBumping){
        if(xSpeed < 0){
            xSpeed *= -0.5;
    if(rightBumping){
        if(xSpeed > 0){
            xSpeed *= -0.5;
    if(upBumping){
        if(ySpeed < 0){
            ySpeed *= -0.5;
    if(downBumping){
        if(ySpeed > 0){
            ySpeed *= -0.5;
        xSpeed *= friction;
        ySpeed *= friction;
        scrollX -= xSpeed;
        scrollY -= ySpeed;
        Ground.x = scrollX;
        Ground.y = scrollY;

    click file>publish settings>swf and tick "permit debugging".  retest.
    the line number of the code that references a non-existant object will be in the error message.
    if you need more help than that, indicate the copy and paste the error message and the line number referenced at the top of the error message.

  • Platform game

    I am a new programmer and ive been through a few tutorials and stuff but now i am trying to make a platform game without just typing from a tutorial. So far all ive been able to do is load and display a ground sprite. I think the next step is to somehow draw the game level using an array with letters to represent different objects(I think thats how most people do it) I have searched everywhere and so far havent found any help though.
    My second question is can someone give me a list of commonly used functions that would help me develope my game.
    Thanks to anyone who helps.

    Hi there,
    I made a java game engine. I really help for those whose start learning java from gaming purposes.
    It is really simple to follow, and pretty fast to create a game.
    Just visit this link and download the library:
    [http://fly.engine.googlepages.com/|http://fly.engine.googlepages.com]
    sample game is provided.
    Hope it really help you.
    Good luck!

  • Platform game code

    Hi guys - Been playing super mario bros with the kids (for them of course). I'm a amateur coder but pretty clued up on AS3 - just not with gaming concepts.
    I would like like to create a platform game - character jumps, climbs etc... onto platforms over objects etc...
    Most coding is quite easy BUT the jumping onto the platform - has anybody got a tut out there. Been googling but fed up with so many bad tuts.
    Just a bit of code for hero to land on platform.
    Suppose I would just hittest and equte the x coordinates of each etc... But how do I get the hero to stand on the platform not.
    Would I just stop the hero falling ie: where the hittest occurs is where the hero will stand. Would that code sit on the hero or on the platforms.

    OK thanks, I'll try that and I suppose I will learn a lot more.
    Cheers

  • Platform game - disable jump when falling

    Hello everyone,
    I'm making a platform game in AS3. I've sorted the left,
    right and jumping movement of my character - apart from one jumping
    problem:
    When the up arrow key is down it sets the jump var to true.
    ENTER_FRAME function detects when jump = true and it decreases the
    characters y position by the var velocity while at the same time
    decreasing velocity by 1.5px. So my character jumps up to a certain
    height then comes down - great! There is a hit test to stop the
    jump/fall.
    BUT when the character falls off a platform he can still jump
    when the up arrow is pressed. I've been racking my brains but I can
    stop the character from jumping if its falling.
    Code aqttached.
    Any help would be MUCH appreciated.
    Thanks,
    Ryan

    on ENTER_FRAME the velocity var is decreasing while the jump
    var is true. This is true when the up arrow as been pressed and
    isn't false until the character hits the ground. Therefore pressing
    the up arrow again while in the air (from a jump) dose not effect
    anything.
    You second answer is closer to the solution, I've tried this
    approach before, but it badly effects the jump.
    This 'else' part of the code controls the character to fall
    if not hitting the ground:
    stage.addEventListener(Event.ENTER_FRAME, hitCheck);
    function hitCheck(event:Event):void
    if (ball_mc.hitTestObject(ground_mc))
    jump = false;
    velocity = 35;
    else
    ball_mc.y += 16;
    If I cancel the jump function in the else then as soon as the
    char starts the jump and is not hitting the ground it will fall
    back to the ground. I hope that makes sense?
    Thanks,
    Ryan
    Text
    Text

  • Adobe Flash CS5 Platform Game Movement With Arrow Keys Help!?

    Hello, I am a beginner to flash gaming. I am making a platform game, but  can not reverse my character when he goes backwards. This is my code  for left and right:
    if (Key.isDown(Key.RIGHT)) {
    _x += speed;
    if (Key.isDown(Key.LEFT)) {
    _x -= speed;
    How Can I reverse it so when it goes LEFT, the character turns all the  way around?

    Ok, I fiured it all out, the other way you mentioned. Just opened up the character MC, and named 2 frames. One LEFT and one RIGHT. Then I added a few simple lines of code, and turned out with this:
    if (Key.isDown(Key.RIGHT)) {
    _x += speed;
    this.gotoAndStop("right");
    if (Key.isDown(Key.LEFT)) {
    _x -= speed;
    this.gotoAndStop("left");
    Thanks for helping!!!

  • How to make a vertical lift or elevator in a platform game

    I am creating a side scrolling platform game using the book "Flash Game University" by Gary Rosenzweig.
    My protagonist has an instance of "hero".
    My current issue is trying to create a lift or elevator to carry the player up or down. The lift is not covered in the book. My thoughts were that the lift constantly moved up and down at a pace determined by a timer. I cannot get my lift to move. I have created a movie clip called "lift" and made it exported for action script. I can make it act similar to a floor movie clip so that I can stand on it, but I cannot get the lift to move on the y axis.
    I tried creating a new function called lift() and using a for loop to count between 0 and 100 using a variable "i" and then make my lift move up 1 unit for each loopcycle. It didn't work.
    lift.y -= lift.y - 1;
    Does anyone have a better solution?
    Thanks,
    Alex

    Rob,
    This worked. Here is my current code ...
    var topIndex:Number = 20;
                        var bottomIndex:Number = 160;
                        var stepDistance:Number = 10;
                        var movingUp:Boolean = true;
    public function createLift()
                                            box = new Object();
                                            box.mc = gamelevel.box;
    public function moveMyLift():void
                                            // lift 01
                                            if (movingUp && box.mc.y > topIndex)
                                                      box.mc.y -= stepDistance;
                                            else
                                                      movingUp = false;
                                              if (!movingUp && box.mc.y < bottomIndex)
                                                      box.mc.y += stepDistance;
                                            else
                                                      movingUp = true;
                                            if (hero.mc.hitTestObject(box.mc))
                                                      hero.mc.y = box.mc.y;
    My lift works correctly. It moves up and down correctly and when I jump on it I stay moving on it. There are only 3 things that don't make sense.
    1. When I am on the elevator I cannot jump. If I am not on the elevator I can jump normally.
    2. When I touch any portion of the elevator, my character automatically repositions itself to stand on the elevator. It seems normal, but not something that should happen in my scenario. I only want to "climb" on the elevator if I touch the "top" of the elevator.
    3. If I add a second elevator, even with its own function, the timing of the elevator math appears to synch instead of work independently. Why? The two elevators synch their movement and timing. Also the first elevator stutters as the synching of the two elevators match thier movement and then moves in unison with the second elevator. Why are they not operating separately?
    Here is the code for the first and second elevator:
    private var box:Object;
    private var box02:Object;
    var topIndex:Number = 20;
    var bottomIndex:Number = 160;
    var stepDistance:Number = 10;
    var movingUp:Boolean = true;
    var topIndexLift02:Number = 1;
                        var bottomIndexLift02:Number = 100;
                        var stepDistanceLift02:Number = 4;
    public function createLift()
                                            box = new Object();
                                            box.mc = gamelevel.box;
                                            box02 = new Object();
                                            box02.mc = gamelevel.box02;
    public function moveMyLift():void
                                            // lift 01
                                            if (movingUp && box.mc.y > topIndex)
                                                      box.mc.y -= stepDistance;
                                            else
                                                      movingUp = false;
                                              if (!movingUp && box.mc.y < bottomIndex)
                                                      box.mc.y += stepDistance;
                                            else
                                                      movingUp = true;
                                            if (hero.mc.hitTestObject(box.mc))
                                                      hero.mc.y = box.mc.y;
                                  public function moveMyLift02():void
                                            // lift02
                                            if (movingUp && box02.mc.y > topIndexLift02)
                                                      box02.mc.y -= stepDistanceLift02;
                                            else
                                                      movingUp = false;
                                              if (!movingUp && box02.mc.y < bottomIndexLift02)
                                                      box02.mc.y += stepDistanceLift02;
                                            else
                                                      movingUp = true;
                                            if (hero.mc.hitTestObject(box02.mc))
                                                      hero.mc.y = box02.mc.y;
    public function gameLoop(event:Event)
                                            // get time difference
                                            if (lastTime == 0) lastTime = getTimer();
                                            var timeDiff:int = getTimer() - lastTime;
                                            lastTime += timeDiff;
                                            // only perform tasks if in play mode
                                            if (gameMode == "play")
                                                      moveCharacter(hero,timeDiff);
                                                      moveEnemies(timeDiff);
                                                      checkCollisions();
                                                      scrollWithHero();
                                                      createLift();
                                                      moveMyLift();
      moveMyLift02();
    Thank you,
    Alex
    Message was edited by: ajdove

  • A beginner trying to create platform game

    I'm a new programmer and just learning Java from the dummies books... I'm trying to make this Java platform game applet that I guess plays like Megaman/Mario/Castlevania.
    Hmm my question would be that my applet slows down a lot on browsers, and I would like to learn how to double buffer as I've seen people suggest on this forum.
    Also I would like to know why the sound doesn't seem to work on 99% of the people who try it.
    You can check the game here: http://www.info.com.ph/~arivera/game/testmain.html
    And the source code is here: http://www.info.com.ph/~arivera/game/source
    Please give suggestions... my code is still very messy and unoptimized too, please bear with me.
    (Updates may occur on the game itself while I work on it.)

    There's two things you'll want to think about implementing in your applet - active rendering and double buffering as you mentioned.
    Active rendering consists of drawing to the screen in the same thread that runs the game applet. By default, when you call repaint(), the AWT Event thread handles the repainting and gets around to repainting the screen whenever it feels like doing so - sometimes not at all! (well, that's not entirely true, but you get the idea)
    Double buffering entails writing to an offscreen buffer, and then drawing that buffer to the screen.
    Thankfully, both are relatively easy to implement.
    Active rendering is the easier of the two to implement. In your game loop, where you call repaint(), don't! Instead, call paint() directly and use the applets getGraphics() method, which will return a Graphics or Graphics2D object for you to use. So instead of having repaint(), replace it with paint(getGraphics());
    Double buffering is a bit more complicated to implement. I'd suggest trying this after you've tried active rendering. Double buffering includes have an Image field in your applet class. I often call it 'buffer', but there's quite a few other common names you'll come across for it.
    To initialize the image, call the applet's createImage(width, height) method. This will return an Image object. You can get a Graphics object that corresponds to that image by calling its getGraphics() method just like you do with active rendering. You no longer want to have all of the painting being done in the paint() method of your applet. Instead, a new method is in order to handle the painting of the game screen to the buffer. Your paint method then should simply call g.drawImage(...) and draw the backbuffer to the screen.
    A small example:
    public class doubleBufferApplet implements Applet
    Image buffer;
    . . . //Other fields
    public void init()
    buffer = createImage(getWidth(), getHeight()); //returns an Image object the size of the applet and assigns it to buffer
    . . . //Do other initializing
    public void run()
    while(gameIsStillRunning) //Main game loop
    . . . //Run through and update the game
    if(buffer != null)
    drawGame(buffer.getGraphics()) //Draw the game to the backbuffer
    paint(getGraphics()); //Draw the backbuffer to the screen
    public void drawGame(Graphics g)
    . . . //Do your painting here
    public void paint(Graphics g)
    if(buffer != null)
    g.drawImage(buffer, 0, 0, this);
    public void update(Graphics g) //Override the default update() method to avoid Java from calling it randomly
    paint(g);
    I hope that gave you a decent idea of how to go about implementaing active rendering and a buffer. If not, I'll try harder to answer any questions you have (or some of the more experienced users around here will help you out as well I'm sure).

  • Edge Animate platformer Game

    Hi, i was wondering if anyone had made a edge animate platformer game already.
    like Mario and Sonic are platformer 2d games.
    i'm kinda stuck on the collision part of it.
    there almost none DOM ( div) based games source codes available, almost all html5 games are canvas based.
    there is a collision jquery plugin available but that one mainly registers if it hits a corner, like the northwest corner, and that is both top and left side. so that isn't usefull when needing only one side.
    so i was wondering if someone could help me out here.

    Hi, i was wondering if anyone had made a edge animate platformer game already.
    like Mario and Sonic are platformer 2d games.
    i'm kinda stuck on the collision part of it.
    there almost none DOM ( div) based games source codes available, almost all html5 games are canvas based.
    there is a collision jquery plugin available but that one mainly registers if it hits a corner, like the northwest corner, and that is both top and left side. so that isn't usefull when needing only one side.
    so i was wondering if someone could help me out here.

  • Looking for platform game app

    i'm looking for similar 2D platform games app similar to Super Mario Bros. for NDS or maybe Prince of persia...free or otherwise. thanks.

    onslaught,
    I really like bounce on it feels a lot like Super Mario Bros. To me. You can try out the lite version for free. http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=303583418&mt=8 The final version though is $ 3.99 found here: http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=300438180&mt=8
    Also if you looking for a great shooter/vampire game I would look into iDracula its only $0.99 and it for me it provides endless fun.The demo is here: http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=309062653&mt=8 and the full version is here: http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=305196662&mt=8
    Hope that helps,
    Weston

  • Where to start with a simple platform game?

    What resources should I look at to learn how to create a very simple platform game, with a charactor who can simply jump on platforms and avoid enemies to reach the end of the level?
    I have made games like this with other languages but never flash.
    Thanks.

    I am also interested in this answer but in my case from the aspect of Silverlight-only developer with no flash experience (I know that sucks
    Thanks,
    Nikola

  • Platform Game with hills

    I want to make a platformer game like super mario. But I want
    my game to have hills in it.
    There is a very famous flash game called Fancy Pants
    Adventure 2. It is a platformer with hills in it.
    I want to know how to do that. I can make a platformer game
    using hitTest(); but that only works with boundary boxes and not
    diagonal and curved objects (like hills). I have looked all over
    the internet to find out how to do this but I can not find my
    answer. If you know how to do this then you are absolutely amazing
    in my eyes and could you please explain to me how to do it.
    Thank you

    So there is no way for flash to see if two objects collide
    without boundary boxes with actionscript. Motion guides would take
    forever if they are what I think they are.

  • How do I fix the FPS in my platform game?

    Hi everyone! As part of a course in Gamemaking in school, my team created a platformer with a colission-map instead of tiles. This has worked out well for the most part.
    My problem is that we have a loop that updates and draws everything to the screen ( this is in windowed mode by the way ) . The game runs and the gameplay is ok.
    But it runs with different speed depending on the hardware. On my computer everything is slow, but on new computers the objects race back and forth like mad. Furthermore sometimes as the player dies and the level restarts, the player dies on the spot!
    From what I have read this is due to the fact that we haven´t fixed the FPS. But Im at a loss as to how im supposed to fix it. One sollution tells me to use a timer and then place logic inside actionPerforemed, but since I am using a loop inside run() this cant work.
    The program is divided into several classes, but the main logic residen in the class main,java
    public Main(){
              super("Mimic");
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);          
              setVisible(true);
              this.enableEvents(KeyEvent.KEY_PRESSED | MouseEvent.MOUSE_DRAGGED);     
              setSize(1280, 720);
              setResizable(false);
              setLocationRelativeTo(null);
              requestFocusInWindow();
              AudioPlayer.loadClip("transform", "sound/transform2.wav");
              AudioPlayer.loadClip("gameover", "sound/gameover.wav");
              AudioPlayer.loadClip("ambient", "sound/test.wav");
              AudioPlayer.loadClip("jump", "sound/jump.wav");
              //Cursor - 1x1px
              Toolkit toolkit = Toolkit.getDefaultToolkit();
              Image transparent = toolkit.getImage("images/empty_pixel.gif");
              Point hotSpot = new Point(0,0);
              Cursor game = toolkit.createCustomCursor(transparent, hotSpot, "transparent");
              setCursor(game);
              createBufferStrategy(3);
              transformationTimer = new Timer(1000, this);
              transformationTimer.setInitialDelay(0);
    geyserTimer = new javax.swing.Timer(1000, new ClockListenerGeyser());
    geyserTimer.start();
              mimicTimerBarBackground = new ImageIcon("images/mimic-bar-bgr.png").getImage();
              mimicTimerBar = new ImageIcon("images/mimic-bar.png").getImage();          
              start();
         }//public
    public void start(){
              (new Thread(this)).start();
         }//start
         public void run(){
              avatar = new Avatar();
         //Ambient sound
         //AudioPlayer.play("ambient", true); Musiken avstängd...
         loadLevel(Map.Levelname.LevelOne);
              //loadLevel(Map.Levelname.LevelTwo);
              long start = System.nanoTime();
              long delta = 0;
              long sleep;
              while(gameOn){ // game loop
                   tick(delta);
                   draw();                    
                   delta = System.nanoTime() - start;
                   sleep = DELAY - delta;
                   // detta är en test för att kolla om loopen fortfarande har tid kvar att göra saker, om den har det, sov och ge den en//
                   start = System.nanoTime();
                   //tick(delta);
                   //draw();               
              }//while
              System.exit(0);
    }//run
    //i den här metoden ligger allt motor, kollision, styrning och scrollning m.m
         public void tick(long tid) {
              float timeScale = tid/100000000f;
                   avatar.update(tid); //animationen uppdateras
                   currentMap.tick(tid);
                   // update mimics
    // lots of codes for Keys, colissionmap and more here.
         public void draw(){
              Graphics g = getBufferStrategy().getDrawGraphics();
              g.translate(-cameraX,-cameraY);          
              g.drawImage(currentMap.collisionMap, 0, 0, null);
         for(Background b: currentMap.getBackgrounds()){
              if(b.isVisible())
                   g.drawImage(b.getImage(),(int)b.getX(), (int)b.getY(), null);
         }//for
         for(MapItems mi: currentMap.getItemList()){
              g.drawImage(mi.getImage(),(int)mi.getX(), (int)mi.getY(), null);           
         }//for
         for(Mimics m: currentMap.getList()){
              if(m.getVisas()){
                   g.drawImage(m.getImage(), (int)m.getX(), (int)m.getY(), null);
              }//if
         }//for
         g.drawImage(avatar.getImage(), (int)avatar.getX(), (int)avatar.getY(), null);
         if (currentMap.levelname == Map.Levelname.LevelTwo){
              g.drawImage(grass, 0, 623, null);
         g.drawImage(key, cameraX+1000, cameraY+72, null);
         g.drawImage(sekLevel, 800, 580, null);
              //Visar timern om den är aktiv
              if (transformationTimer.isRunning()) {
                   g.drawImage(mimicTimerBarBackground, cameraX+509, cameraY+72, null);
                   g.drawImage(mimicTimerBar, cameraX+514, cameraY+77, (int)(cameraX+514+(200/20)*transformationTime), cameraY+77+30, 0, 0, (int)(200/20)*transformationTime, 30, null);
              g.setColor(Color.red);      
              g.dispose();
         getBufferStrategy().show();
         }//void
    I figure I got to put a timer to fix the FPS somewhere in here, but where?
    Any help is greatly appreciated!
    Regard,
    Gabriel

    Speed should be 'tick' based. The way I do it, with silky smooth results, is to lock the game to a framerate. That part is quite easy, all you do is calculate at what interval you want to update. Say you want 60FPS, it becomes:
    interval = 1000 / 60 (interval = 17ms).
    So if you want 60FPS, you have to update and draw every 17 milliseconds. That sounds like a short time, but for computers it really is not.
    Okay, so you have your game loop. while(true) { update(); render(); }. The body of this loop should execute every 17ms (it won't be that precise, but it will be good enough). It goes a little something like this:
    while(running){
    long measure1 = currentTimeInMillis();
    update();
    render();
    long measure2 = currentTimeInMillis();
    long diff = measure2 - measure1;
    Thread.sleep(17-diff); // sleep until next tick
    }This will have the game ticking at 58-61 FPS, depending on the timing precision of the OS - you'll find that on Linux OSes the framerate is far more steady than on Windows environments for example, in Java at least. Its just the sleep call that is far from precise.
    Now you will want to make movement based on the framerate - the way I do that is to work with float measurements. For movement speed I say 'every tick, move X.X pixels', where I keep the units in increments of 0.5 pixels. This means that moving game entities can go as slow as 0.5 pixels each tick in my games, which is slow enough for most of them. In the end when determining the actual pixel locations, the floats are rounded down to ints.
    I hope that makes some sense.

  • Help with platform game

    I can't solve this for days already... When the hero object dies, the floorObject do not remove completely, such that one of them remains. And the hero object
    disappears. Thanks for all the help.
    package
              import flash.display.MovieClip;
              import flash.events.KeyboardEvent;
              import flash.events.*;
              import flash.utils.getTimer;
              public class Platform extends MovieClip
                        // movement constants
                        static const gravity:Number = .004;
                        // screen constants
                        static const edgeDistance:Number = 100;
                        // object arrays
                        private var fixedObjects:Array;
                        private var otherObjects:Array;
                        // hero and enemies
                        private var hero:Object;
                        private var enemies:Array;
                        // game state
                        private var playerObjects:Array;
                        private var gameScore:int;
                        private var gameMode:String = "start";
                        private var playerLives:int;
                        private var lastTime:Number = 0;
                        private var currentX:int = 0;
                        public function startPlatformGame()
                                  // constructor code
                                  gameMode = "play";
                        public function startGameLevel()
                                  createHero();
                                  addEnemies();
                                  // examine level and note all objects
                                  examineLevel();
                                  // add listeners
                                  this.addEventListener(Event.ENTER_FRAME,gameLoop);
                                  stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownFunction);
                                  stage.addEventListener(KeyboardEvent.KEY_UP,keyUpFunction);
                                  // set game state
                                  gameMode = "play";
                        public function createHero()
                                  hero = new Object();
                                  hero.mc = gamelevel.hero;
                                  hero.dx = 0.0;
                                  hero.dy = 0.0;
                                  hero.inAir = false;
                                  hero.direction = 1;
                                  hero.animstate = "stand";
                                  hero.walkAnimation = new Array(2,3,4,5,6,7,8);
                                  hero.animstep = 0;
                                  hero.jump = false;
                                  hero.moveLeft = false;
                                  hero.moveRight = true;
                                  hero.jumpSpeed = .8;
                                  hero.walkSpeed = .15;
                                  hero.width = 30.0;
                                  hero.height = 40.0;
                                  hero.startx = hero.mc.x;
                                  hero.starty = hero.mc.y;
                        public function addEnemies() {
                                  enemies = new Array();
                                  var i:int = 1;
                                  while (true) {
                                            if (gamelevel["enemy"+i] == null) break;
                                            var enemy = new Object();
                                            enemy.mc = gamelevel["enemy"+i];
                                            enemy.dx = 0.0;
                                            enemy.dy = 0.0;
                                            enemy.inAir = false;
                                            enemy.direction = 1;
                                            enemy.animstate = "stand"
                                            enemy.walkAnimation = new Array(2,3,4,5);
                                            enemy.animstep = 0;
                                            enemy.jump = false;
                                            enemy.moveRight = true;
                                            enemy.moveLeft = false;
                                            enemy.jumpSpeed = 1.0;
                                            enemy.walkSpeed = .08;
                                            enemy.width = 30.0;
                                            enemy.height = 30.0;
                                            enemies.push(enemy);
                                            i++;
                        public function examineLevel()
                                  fixedObjects = new Array();
                                  otherObjects = new Array();
                                  for (var i:int=0; i<this.gamelevel.numChildren; i++)
                                            var mc = this.gamelevel.getChildAt(i);
                                            // add floors and walls to fixedObjects
                                            if (mc is Floor)
                                                      var floorObject:Object = new Object();
                                                      floorObject.mc = mc;
                                                      floorObject.leftside = mc.x;
                                                      floorObject.rightside = mc.x + mc.width;
                                                      floorObject.topside = mc.y;
                                                      floorObject.bottomside = mc.y + mc.height;
                                                      fixedObjects.push(floorObject);
                                            else if ((mc is Treasure) )
                                                      otherObjects.push(mc);
                                  fixedObjects.sortOn("leftside" , Array.NUMERIC );
                                  for each (floorObject in fixedObjects)
                                            trace(floorObject.leftside);
                        // add treasure, key and door to otherOjects;
                        public function keyDownFunction(event:KeyboardEvent)
                                  if (gameMode != "play")
                                            return;
                                  }// don't move until in play mode
                                  if (event.keyCode == 37)
                                            hero.moveLeft = true;
                                  else if (event.keyCode == 39)
                                            hero.moveRight = true;
                                  else if (event.keyCode == 32)
                                            if (! hero.inAir)
                                                      hero.jump = true;
                        public function keyUpFunction(event:KeyboardEvent)
                                  if (event.keyCode == 37)
                                            hero.moveLeft = false;
                                  else if (event.keyCode == 39)
                                            hero.moveRight = false;
                        public function gameLoop(event:Event)
                                  // get time differentce
                                  if (lastTime == 0)
                                            lastTime = getTimer();
                                  var timeDiff:int = getTimer() - lastTime;
                                  lastTime +=  timeDiff;
                                  // only perform tasks if in play mode
                                  if (gameMode == "play")
                                            moveCharacter(hero,timeDiff);
                                            checkCollisions();
                                            scrollWithHero();
                                            death();
                        public function moveCharacter(char:Object,timeDiff:Number)
                                  if (timeDiff < 1)
                                            return;
                                  // assume character pulled down by gravity
                                  var verticalChange:Number = char.dy * timeDiff + timeDiff * gravity;
                                  if (verticalChange > 15.0)
                                            verticalChange = 15.0;
                                  char.dy +=  timeDiff * gravity;
                                  // react to changes from key presses
                                  var horizontalChange = 0;
                                  var newAnimState:String = "stand";
                                  var newDirection:int = char.direction;
                                  if (char.moveLeft)
                                            // walk left
                                            horizontalChange =  -  char.walkSpeed * timeDiff;
                                            newAnimState = "walk";
                                            newDirection = -1;
                                  else if (char.moveRight)
                                            // walk right
                                            horizontalChange = char.walkSpeed * timeDiff;
                                            newAnimState = "walk";
                                            newDirection = 1;
                                  if (char.jump)
                                            // start jump
                                            char.jump = false;
                                            char.dy =  -  char.jumpSpeed;
                                            verticalChange =  -  char.jumpSpeed;
                                            newAnimState = "jump";
                                  // assume no wall hit, and hanging in air
                                  char.hitWallRight = false;
                                  char.hitWallLeft = false;
                                  char.inAir = true;
                                  // find new vertical position
                                  var newY:Number = char.mc.y + verticalChange;
                                  // loop through all fixed objects to see if character has landed
                                  for (var i:int=0; i<fixedObjects.length; i++)
                                            if ((char.mc.x+char.width/2 > fixedObjects[i].leftside) && (char.mc.x-char.width/2 < fixedObjects[i].rightside))
                                                      if ((char.mc.y <= fixedObjects[i].topside) && (newY > fixedObjects[i].topside))
                                                                newY = fixedObjects[i].topside;
                                                                char.dy = 0;
                                                                char.inAir = false;
                                                                break;
                                  // find new horizontal position
                                  var newX:Number = char.mc.x + horizontalChange;
                                  // loop through all objects to see if character has bumped into a wall
                                  for (i=0; i<fixedObjects.length; i++)
                                            if ((newY > fixedObjects[i].topside) && (newY-char.height < fixedObjects[i].bottomside))
                                                      if ((char.mc.x-char.width/2 >= fixedObjects[i].rightside) && (newX-char.width/2 <= fixedObjects[i].rightside))
                                                                newX = fixedObjects[i].rightside + char.width / 2;
                                                                char.hitWallLeft = true;
                                                                break;
                                                      if ((char.mc.x+char.width/2 <= fixedObjects[i].leftside) && (newX+char.width/2 >= fixedObjects[i].leftside))
                                                                newX = fixedObjects[i].leftside - char.width / 2;
                                                                char.hitWallRight = true;
                                                                break;
                                  // set position of character
                                  char.mc.x = newX;
                                  char.mc.y = newY;
                                  // set animation state
                                  if (char.inAir)
                                            newAnimState = "jump";
                                  char.animstate = newAnimState;
                                  // move along walk cycle
                                  if (char.animstate == "walk")
                                            char.animstep +=  timeDiff / 60;
                                            if (char.animstep > char.walkAnimation.length)
                                                      char.animstep = 0;
                                            char.mc.gotoAndStop(char.walkAnimation[Math.floor(char.animstep)]);
                                            // not walking, show stand or jump state
                                  else
                                            char.mc.gotoAndStop(char.animstate);
                                  // changed directions
                                  if (newDirection != char.direction)
                                            char.direction = newDirection;
                                            char.mc.scaleX = char.direction;
                        public function checkCollisions()
                                  for (var i = otherObjects.length-1; i >= 0; i--)
                                            if (hero.mc.hitTestObject(otherObjects[i]))
                                                      getObject(i);
                                  for (var j:int = enemies.length-1; j>=0; j--)
                                            if (hero.mc.hitTestObject(enemies[j].mc))
                                                      currentX = hero.mc.x;
                                                      gameComplete();
                        public function scrollWithHero()
                                  var stagePosition:Number = gamelevel.x + hero.mc.x;
                                  var rightEdge:Number = stage.stageWidth - edgeDistance;
                                  var leftEdge:Number = edgeDistance;
                                  if (stagePosition > rightEdge)
                                            gamelevel.x -= (stagePosition-rightEdge);
                                            if (gamelevel.x < -(gamelevel.width-stage.stageWidth))
                                                      gamelevel.x = -(gamelevel.width-stage.stageWidth);
                                  if (stagePosition < leftEdge)
                                            gamelevel.x += (leftEdge-stagePosition);
                                            if (gamelevel.x > 0)
                                                      gamelevel.x = 0;
                        public function getObject(objectNum:int)
                                  if (otherObjects[objectNum] is Treasure)
                                            gamelevel.removeChild(otherObjects[objectNum]);
                                            otherObjects.splice(objectNum,1);
                        public function death()
                                  if (hero.mc.y > 300)
                                            currentX = gamelevel.hero.x;
                                            trace(currentX);
                                            gameComplete();
                        public function gameComplete()
                                  gameMode = "dead";
                                  var dialog:Dialog = new Dialog();
                                  dialog.x = 175;
                                  dialog.y = 100;
                                  addChild(dialog);
                                  dialog.message.text = "Gameover";
                        public function clickDialogButton(event:MouseEvent)
                                  removeChild(MovieClip(event.currentTarget.parent));
                                  // new life, restart, or go to next level
                                  if (gameMode == "dead")
                                            // reset hero
                                            hero.mc.x = currentX;
                                            hero.mc.y = 0;
                                            trace("dead");
                                            setReplay();
                                            gameMode = "play";
                                  // give stage back the keyboard focus
                                  stage.focus = stage;
                        public function setReplay()
                                  for (var i:int = fixedObjects.length-1; i>-1; i--)
                                            if (fixedObjects[i].leftside < currentX)
                                                      this.gamelevel.removeChildAt(fixedObjects[i]);
                                                      fixedObjects.splice(i,1);
                                                      trace("Splice?");
                                  for each (var floorObject in fixedObjects){
                                            trace(floorObject.leftside);
                        public function cleanUp()
                                  removeChild(gamelevel);
                                  this.removeEventListener(Event.ENTER_FRAME,gameLoop);
                                  stage.removeEventListener(KeyboardEvent.KEY_DOWN,keyDownFunction);
                                  stage.removeEventListener(KeyboardEvent.KEY_UP,keyUpFunction);

    Ok, I fiured it all out, the other way you mentioned. Just opened up the character MC, and named 2 frames. One LEFT and one RIGHT. Then I added a few simple lines of code, and turned out with this:
    if (Key.isDown(Key.RIGHT)) {
    _x += speed;
    this.gotoAndStop("right");
    if (Key.isDown(Key.LEFT)) {
    _x -= speed;
    this.gotoAndStop("left");
    Thanks for helping!!!

Maybe you are looking for

  • Help required in starting to learn Flex 3

    Hi All,  I want to start learning Adobe Flex 3.  I have various questions.  1) What is the difference between adobe flex builder 3 and adobe sdk 3.0  I have heard that flex builder 3 is commercial and adobe sdk is freely downloadable. I would like to

  • Edits of Reports and Forms not in log

    I created an edit report from wwlog_activity_logs but it does not include report edits since wwlog_activity_logs does not. Is there another view or table where I can get this information? Note: the log registry is wide open so everything that can be

  • ERROR...ERROR...ERROR... please, help me!!

    I'm trying to install i-tunes software included in my new i-pod. It doesn't work at all. The message is "String PRODUCT_NAME was not found in string table", and then, "Error Number: 0x80040706 - Description: Object reference not set......... set up w

  • Java Sqlite Driver Installation

    Hi I need to install javasqlite-20060714.tar.gz in Redhat Linux (Version 5). I already installed java 1.5.0_22 and SQLite 3.7.4 in Linux. Can anyone tell me the installation procedure and also how to test java with SQLite? Wheather we need C compiler

  • Can't connect to windows xp via server name

    I have a network via Airport Express: imac  10.6.8 and PC windows XP sp3 Suddenly, without any reason, I got this issue: I can't see the PC in on left  share bar  of Finder windows. The only way to see the PC is :  go > connect to server" > server ad