Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Robots – An Eclipse Plug-in Game

DZone's Guide to

Robots – An Eclipse Plug-in Game

· Java Zone ·
Free Resource

Bring content to any platform with the open-source BloomReach CMS. Try for free.

Quite similar with a traditional Linux robot game, with a simple teleport, implements by Eclipse plug-in. You can create your own robots by extending ‘robot’ extension point.

Get the Game  plugins.zip

Game window:

Win screen:

Launch the Game: Copy jars into [eclipse base dir]/plugins, restart eclipse studio, Menu-Window-Show View-Other-Game-’Robot Game’.

View extension of robot:

Robot extension point:

 

Create your own robot, you need to define:routing class, image, power(1 to 5, the player is zero, so it can be defeated by any other robots), name, count(total on game start), speed(steps in once route).

Robot1.java(sample)

import java.util.Random;
 
import org.eclipse.swt.graphics.Point;
 
import com.osgix.game.robot.game.RobotGame;
import com.osgix.game.robot.robot.AbstractRobot;
 
public class Robot1 extends AbstractRobot {
 
    @Override
    public boolean move() {
        moveToPlayer();
        return true;
    }
 
    @Override
    public void newGame(RobotGame game) {
        Random generator = new Random();
        Point p = new Point(0, 0);
        do {
            p.x = generator.nextInt(game.getMapX());
            p.y = generator.nextInt(game.getMapY());
        } while (game.hasRobots(p));
        setPosition(p);
    }
}

 provide by yanbasic, enjoy it :-)

BloomReach CMS: the API-first CMS of the future. Open-source & enterprise-grade. - As a Java developer, you will feel at home using Maven builds and your favorite IDE (e.g. Eclipse or IntelliJ) and continuous integration server (e.g. Jenkins). Manage your Java objects using Spring Framework, write your templates in JSP or Freemarker. Try for free.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}