Old Style Game Framework How To..

Creating a Game with Old Style Game Framework.

This walk through create a side scroller game, where the player runs across the screen and jumps over obstacles. The walk through uses the Old Style Game Framework (1.0.2), Game Doc (1.2.3) and Game Designer (1.2.2).

Updated versions: Old Style Framework (1.1), Game Doc (1.3) and Game Designer (1.3)

FireBall.java
006 package org.deken.sidescroller.sprites;
007 
008 import org.deken.game.movement.GameVector;
009 import org.deken.game.sprites.BaseActor;
010 import org.deken.game.sprites.Sprite;
011 import org.deken.game.sprites.SpriteSize;
012 import org.deken.game.utils.GameLog;
013 import org.deken.sidescroller.AdventureMap;
014 
015 /**
016  <p>
017  * Title: FireBall</p>
018  *
019  <p>
020  * Description: </p>
021  *
022  * Copyright: Copyright (c) Aug 15, 2014
023  *
024  @author Gary Deken <gary@abberkeep.us>
025  @version 1.0
026  */
027 public class FireBall extends BaseActor {
028    private boolean active = false;
029    private boolean missed = true;
030    private boolean notCounted = true;
031    private Jumper jumper;
032    private AdventureMap map;
033 
034    public FireBall(SpriteSize spriteSize) {
035       super(spriteSize);
036    }
037 
038    @Override
039    public BaseActor copy() {
040       FireBall newFireball = new FireBall(size.copy());
041       copyBase(newFireball);
042       return newFireball;
043    }
044 
045    public boolean isActive() {
046       return active;
047    }
048 
049    public boolean isMissed() {
050       return missed;
051    }
052 
053    public void setActive(boolean active) {
054       this.active = active;
055    }
056 
057    public void setMissed(boolean miss) {
058       this.missed = miss;
059    }
060 
061    public void setUp(Jumper jumper, AdventureMap map) {
062       notCounted = true;
063       this.jumper = jumper;
064       this.map = map;
065    }
066 
067    @Override
068    protected void spriteCollison(Sprite collideSprite) {
070       super.spriteCollison(collideSprite);
071       movement.getGameVector().setDirection(GameVector.DIRECTION.NULL, 0);
072       missed = false;
073       stillMotion[0= moveMotion[1];
074       map.fireBallHit();
075    }
076 
077    @Override
078    public void update(long elaspeTime) {
079       super.update(elaspeTime);
080       double x = location.x;
081       double pX = jumper.getXLocation();
082 
083       if (x < pX && missed && notCounted) {
084          // update miss counter in Map
085          notCounted = false;
086          map.increaseFireballsPassed();
087       }
088    }
089 
090    @Override
091    protected void updateCurrentMotion() {
092       if (!missed) {
093          // hit player
094       }
095    }
096 
097    @Override
098    protected void updateLocationX() {
099       double newX = GameVector.roundOff(location.getX() + movement.getXUpdate());
100       location.setX(newX);
101    }
102 
103 }
Back