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

Similar Messages

  • 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

  • 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

  • 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.

  • 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!!!

  • 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.

  • 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

  • Hi Team, Showing Yellow icons after every 15 to 20 Min and internet stop working.when we enable- disbale the network connection then will internet start working fine.Some time network connection is disable but when we renable that connection it will st

    Hi Team,
    Showing Yellow icons after every 15 to 20 Min and internet stop working.when we enable- disbale the network connection then will internet start working fine.Some time network connection is disable but when we renable that connection it will stuck on enabling
    and will not renable till i am not restart that machine. I have 350 Machine in network but facing this issue in 25 machines. Kindly help me on this issue .
    Regards
    Sahil bhateja

    Hi,
    So switch a LAN card fix this issue...seems a compatibility issue or maybe some packs or programs you installed recently cause this issue.
    Have you manually check the network adapter driver from the PC's manufacture website? sometimes, it will be a time delay before Microsoft push out the driver update.
    Check if issue exists in safemode with network, this mode will launch Windows with limited sets of files and drivers. 
    if you have a restore point, restore the pc to a previous point at which the pc is functioning fine.
    Yolanda Zhu
    TechNet Community Support

  • When I try to update or install apps on my iphone it tells me my apple id has been disabled but when I go to the pc, I can log in fine.  Can someone help me?

    When I try to update or install apps on my iphone 3gs, it tells me my apple id is disabled, but when I log in on my pc it lets me.  Any ideas what to do?

    Try signing out, then back in on your phone: Settings>Store>Apple ID, tap the ID shown, sign out, sign back in.  If that doesn't work, reset your password here: https://iforgot.apple.com.

  • When i Log into instagram it say my account  is disable but when i log in on another iphone my instagram account log's in. when i try logging into another account it continue to say disable. Why cant i log into instagram or make another one on my iphone?

    When i Log into instagram it say my account  is disable but when i log in on another iphone my instagram account log's in. When i try logging into another account on my phone it continue to say disable. i also tried to make a new instagram on my phone but it wont let me. i deleted the app over and over again but it still wont let me log into any instagram account. Why cant i log into instagram or make another one on my iphone?
    Is is=t possable to have your phone banned from a app forever???
    HELP !!

    I just asked the same thing and did some research. Some people have said  that the UDID code is like banned from instagram, but your account isn't. I'm able to use it on my phone but not on my iPod.

  • How do i disable iMessage from my mac, i have looked at other comments and there is no option to disable it when messages are open

    how do i disable iMessage from my mac, i have looked at other comments and there is no option to disable it when messages are open

    Solution may be found if you search in the "More Like This" section over in the right column.

  • My Ipod Touch is disabled and when I connect to Itunes to recover it, it states that itiTunes could not connect to the iPod touch "iPod touch" because it is locked with a passcode. You must enter your passcode on the iPod touch before it can recover.

    My Ipod Touch is disabled and when I connect to Itunes to recover it, it states that itiTunes could not connect to the iPod touch “iPod touch” because it is locked with a passcode. You must enter your passcode on the iPod touch before it can recover.

    Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
    iOS: Forgot passcode or device disabled
    If recovery mode does not work try DFU mode.                        
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings        
    For how to restore:                                                             
    iTunes: Restoring iOS software
    To restore from backup see:
    iOS: Back up and restore your iOS device with iCloud or iTunes       
    If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
    You can redownload most iTunes purchases by:           
    Downloading past purchases from the App Store, iBookstore, and iTunes Store        
    If problem what happens or does not happen and when in the instructions? When you successfully get the iPod in recovery mode and connect to computer iTunes should say it found an iPod in recovery mode.

  • My daughter has entered the wrong passcode too many times, it is now disabled.  When I connect to iTunes, it will not let me go any further until I enter the correct passcode.  I no longer get the option to do this, all I get is iPOD disabled.  Help

    My daughter has entered the wrong passcode too many times on her iPOD Touch, it is now disabled.  When I connect to iTunes, it will not let me go any further until I enter the correct passcode.  I no longer get the option to do this, all I get is iPOD disabled.  Help Please

    Restore the iPod from the computer to which the iPod is synced. For information and instructions, see:
    http://support.apple.com/kb/ht1212
    If that will not work, you'll need to put the iPod into Recovery Mode and then try the Restore again:
    http://support.apple.com/kb/ht1808
    Regards.
    Forum Tip: Since you're new here, you've probably not discovered the Search feature available on every Communities page, but next time, it might save you time (and everyone else from having to answer the same question multiple times) if you search a couple of ways for a topic, both in the relevant forums and in the Apple Knowledge Base, before you post a question.

Maybe you are looking for