Home Screenshots Download Manual Contact
Coffee Maker v1.3
www.danielseabra.net/coffee

Daniel Seabra de Andrade
www.danielseabra.net


==================
Contents
==================
I. Introduction
II. Instructions
III. License

==================
Introduction
==================
Hey everyone! Having worked with Game Maker for a long time, I know how frustrating it is to move to other languages. With Coffee Maker I'm trying to make it simpler to move from Game Maker to Java. 



Coffee Maker DOES NOT have the same functions as Game Maker. It is purely Java coding. However, it does feature GMObjects, which are "Game Maker Objects." With this class in hand you can easily program events. I sincerely hope that I have eased your quest of moving to another language and I look forward to support you guys in the forums.

~Daniel


==================
Instructions
==================
Coffee Maker is purely Java coding. It includes two crucial files: GMObject.java and Board.java. I will now explain these two files in more detail.



------------------
GMObject.java
------------------

------------------
Variables
------------------
int x = x position of the object
int y = y position of the object
int w = Width of the object 
int h = Height of the object
int depth = Depth for drawing.
String spriteloc = Location of the sprite
Image sprite = The image (set with setImage() or in constructor)
boolean solid = Whether to check for collisions or not (different than Game Maker!)
boolean visible =Used to check whether to draw itself or not (must be done on your own)
Rectangle bounds = Rectangle for collision checking.
boolean deactivated = whether the object is deactivated or not (when deactivated, object doesn't run anything except a special event called deac(), this is so you can reactivate it whenever you wish)
static ArrayList list = array that has all the objects in the game.

------------------
Constructors
------------------
new GMObject() = Basic constructor, use if you will later set the methods by hand (eg object.x=5;)

new GMObject(int x, int y, String spriteloc, boolean solid, boolean visible, int depth) = Constructor used for objects that aren't used for collision checking. Useful for objects with sprites.

new GMObject(int x, int y, int w, int h, String spriteloc, boolean solid, boolean visible, int depth) = Constructor used for objects that are used for collision checking. Make sure to set solid to true if you want it to check for collisions.

------------------
Using
------------------
GMObject.java is what makes Coffee Maker similar to Game Maker. To use it, simply make a new class and extend GMObject. Let's look at the header of "Star.java" in the example to see how this works:

"public class Star extends GMObject"

If you do this, you must also include  a copy of a constructor such as:


"public Star(int x, int y, String spriteloc, boolean solid, boolean visible, int depth)

{

    super(list, x, y, spriteloc, solid, visible, depth);

}"

These two things allow Star.java to extend GMObject and therefore be able to use Game Maker events such as:

public void create()
public void step()
public void draw(Graphics2D g2, Object drawer)



Using these events is not hard. Let's look at Star.java again to see how it is done:

"public void step()
{
	x -= 8;
	
	//If it's gone from screen, make it come back from the right at a random y position.
	if (x < 0)
	{
		x = 642;
		y = (int) (10+Math.random()*460);
        }
}

    
public void draw(Graphics2D g2, Object drawer)
{

    	//Draws itself on the screen.
	if (visible)
	{
		g2.setColor(Color.WHITE);
		g2.drawOval(x, y, 1, 1);
	}
}"

All you have to do is put the code in the event you want it. Please note that the code is STILL JAVA, so basic knowledge of Java is necessary to use Coffee Maker. The basic example included with this package has examples on destroying, creating, and drawing objects.

Make sure that when you want to use an event, it is typed exactly as it is in GMObject.java.

For example, if you wanted to use the draw event, make sure you do:
public void draw(Graphics2D g2, Object drawer)
OR
public void draw(Graphics g, Object drawer)

Both of these options are available in GMObject.java, but you cannot do:
public void draw()
Because that is NOT in GMObject.

That's the basic rundown of the GMObject – just extend it and put the events you want in your objects. For further examples, look at the example included with Coffee Maker.

------------------
Board.java
------------------
Board.java is the basic driver for Coffee Maker. It calls the events in GMObjects and every object that extends GMObject.


It shouldn't have to be necessary to edit Board.java much. You can place your initial objects there, like I did with the ship in the example. Once that's done, you can focus on the objects and go from there (the stars were created in the start event of the ship, for example). 
-----------------

I think the example will help much more than I could ever help with just words.

------------------
Compiling
------------------

To compile, you will need to go to http://www.oracle.com/technetwork/java/javase/downloads/index.html and download and install the JDK. Once you do that, you will need to open Command Prompt and go to the directory where all you .java files are, like so:
cd Desktop
cd Java
cd GameOne

Once you have it in the right spot, you can do:
javac File.java

Where "File" is any java file. The compiler will tell you your mistakes and if you don't have any mistakes, it will make a .class file which is necessary to run the game. If this works, then congratulations, you have compiled a Java Program.

Alternatively, you can download a program that comes with compiling, debugging, and other feature (IDE) such as Eclipse or NetBeans. Both of these are free and very well made.

------------------
Running the Game
------------------

The last thing is running the game. If you have Java installed in your computer, a simple call to:

java Skeleton

from the Command Prompt will initialize the game. The Skeleton need not be called Skeleton. You could copy the code into a "Runner.java", compile it, and then do:

java Runner

Another option, the one I have done, is to include a .bat file with the game. To do this, simply open notepad and write

java Skeleton

And save it as a .bat, not a .txt. Then you can simply open it and it will work. 



If you're using an IDE, you will need to find a run button or some such of running mechanism.


==================
License
==================
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.