2DGE
So I decided to wright a simple little graphics engine for people who either dont want to write their own or arnet to sure.
Features:
custom height,width.
supports offsets.
contains an image reader.
game timer.
multiple draw methods.
custom default image size.
future features:
Font renderer.
layering support.
lighting controller
so here it is enjoy!
2DGE download: https://docs.google.com/file/d/0B48ywWBymi3OLVZtZ1c3LTV3UEk/edit?usp=sharing
Basic usage.
Updated tutorial!
—tutorial—
package GEDEMO;
import GECORE.Ge;//import ant!
import GEGRAPHICS.drawableobj;
import GEGRAPHICS.renderhandler;
import GEINPUT.spritesheet;
import GEINTERFACE.Animation;
public class Tutorial {
private Ge ge;//setup objects
private spritesheet s;
private drawableobj dro;
private drawableobj dro1;
private drawableobj dro2;
private renderhandler rh;
private Animation a;
private Animation a1;
private int[][] data = new int[64][64];//image array, this may change in the future to a sprite object
public static void main(String[] args){
new Tutorial();//basically start.
}
public Tutorial(){
rh = new renderhandler();//generate the render handler
ge = new Ge(600,600,1,"Tutorial",rh,2,2);//set up the frame, width height scale name renderhander(this will be updated so you can add multiple ones) multx multy (for the graphical map size)
rh.setuphandler(ge, 3);//setup the rh with a GEcore and how many objects it will be rendering at most
//s = new spritesheet("spritelocation.png/jpg"); dont have an image so its commented out but put the image location plus the extension in as a string
setup();//called to setup everything before you start the tick loop otherwise it will not load.
ge.start(true);//start the tickloop this will run the graphics and animation timers.
}
public void setup(){
for(int x = 0; x < 64;x++){//dont need to use this is just because i dont have an image. gives a nice effect though :)
for(int y = 0; y < 64;y++){
data[x][y] = x * y * 9999;
}
}
//s.getsprite(0, 0, data, 64, 64);//what would be used to get a 64 by 64 sprite from the x and ypos 0.
dro = new drawableobj(0,0, 64, 64, data, "Tut1"); //turn the data into a drawable object for use in the renderhandler
dro1 = new drawableobj(128,0, 64, 64, data, "Tut2");//just for extras
dro2 = new drawableobj(0,128, 64, 64, data, "Tut3");
rh.addobj(dro1);//add each one to it. We set the max it would render to three so it will only render 3.
rh.addobj(dro2);
rh.addobj(dro);
a = new Animation(16, 16, 4, data, ge,"animation 1");//setup the animations width height frame num datafile(has all frames on it consecutively from left to right) GEcore id
a1 = new Animation(16,16,4,data,ge,"animation 2");
ge.addanimationtimer(a);//used to tick the animation
ge.addanimationtimer(a1);
a.animate(128, 128, 40);//animates the data and then removes it when complete
a1.stop();//used to setup variables and stop all running processes in animation. you must use this before running a repetitive animation.
a1.repetitiveanim(128, 192, 40);//runs until stop is called/
ge.screen.draw(256, 256, data);//a function that draws a 32 by 32 image at the set x and y
ge.screen.draw(512, 256, data,64,64);// the same but with custom bounds
ge.screen.clear(520, 280, 10, 10);//removes an area from the graphical map
}
}
Enjoy lots more features to come.
—updates—
UPDATE 1:
New features:
An auto drawing system called renderhandler();
Now functions as an import type system not a base system.
Setup for GUI’s.
New way of using images.
UPDATE 2:
New features:
animation handling! horrah!
fixed a bug messing with the rendering.
new commands and a new import file!
new commands.
stop();
animate(x,y,ticks);
repetitiveanim(x,y,ticks);
addanimationtimer(animation);
clear(x,y,width,height);
UPDATE 3:
Tutorial is now up to date.
—Quick thoughts—
So I was having an idea about pushing everything into the ge class so you only require to type Ge. not go Ge.screen Ge.spritesheet.
Along with this maybe implementing input handing and mousehandling maybe rename it to game engine possibly even in the future add in support for tilling and entitys we will see…