PlaneMambo GTGE part-1

Genre Game: Action Adventure..

Mamboplay.java

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package PlaneMambo.main;

import PlaneMambo.game.MamboGame;
import com.golden.gamedev.GameEngine;
import com.golden.gamedev.GameLoader;
import com.golden.gamedev.GameObject;
import java.awt.Dimension;

/**
 *
 * @author me
 */
public class Mamboplay extends GameEngine{

    public static void main(String[] args){
        GameLoader game = new GameLoader();
        game.setup(new MamboGame(), new Dimension(640,480), false);
        game.start();
    }

    @Override
    public GameObject getGame(int GameID) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}

MamboGame.java

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package PlaneMambo.game;

import com.golden.gamedev.Game;
import com.golden.gamedev.object.AnimatedSprite;
import com.golden.gamedev.object.Background;
import com.golden.gamedev.object.Sprite;
import com.golden.gamedev.object.SpriteGroup;
import com.golden.gamedev.object.background.ColorBackground;
import com.golden.gamedev.object.sprite.AdvanceSprite;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;

/**
 *
 * @author me
 */
public class MamboGame extends Game {

    public Background ground;
    //group pemain
    private SpriteGroup Lakon; //untuk pemain

    //Gambar insteance of
    public AdvanceSprite pesawat;
    public BufferedImage[] fireleft,fireright;

    //direction name
    public static final int left =0,
                            right=1,
                            up=2,
                            down=3;

    //constructor
    public MamboGame(){
        //background image
    }

    @Override
    public void initResources() {
        ground = new ColorBackground(Color.BLACK);
        //lokasi gambar
        BufferedImage[] images = getImages("../image/kekuatan_1.png",17, 1);
        fireleft = getImages("../image/bomb1.png",3,1);
        //pemain
        pesawat = new AdvanceSprite(images, 275, 250);

        

        //memasang pesawat diatas background
        pesawat.setBackground(ground);
    }

    @Override
    public void update(long elapsedTime) {
        pesawat.update(elapsedTime);
        if(keyDown(KeyEvent.VK_LEFT)) {
            pesawat.moveX(-0.1*elapsedTime);
            pesawat.setAnimationFrame(4,1);
            pesawat.setDirection(left);
        }else if(keyDown(KeyEvent.VK_RIGHT)){
            pesawat.moveX(0.1*elapsedTime);
            pesawat.setAnimationFrame(12,1);
        }else if(keyDown(KeyEvent.VK_UP)){
            pesawat.moveY(-0.1*elapsedTime);
            pesawat.setAnimationFrame(8,1);
        }else if(keyDown(KeyEvent.VK_DOWN)){
            pesawat.moveY(0.1*elapsedTime);
            pesawat.setAnimationFrame(16,1);
        }
    }

    @Override
    public void render(Graphics2D g) {
        g.setBackground(Color.BLACK);
        ground.render(g);
        pesawat.render(g);
        
    }

public void animationChanged(){}

    //Tembakan dari pesawat
//    class Projectile extends Sprite{
//            public Projectile(MamboGame s){
//                if(animationChanged()){
//
//                }else if(){}
//            }
//    }

}

hasil compile:

Tunggu artikel part-2 jika sempat..:D

3 thoughts on “PlaneMambo GTGE part-1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s