Re: Test de mi gameEngine en processing.
Posted: Sat Aug 05, 2017 9:35 pm
Te dejo un juego que estoy haciendo, de juego tiene bien poco jeje.. pero es para que veas un poco por encima el tipo de resultados que se consiguen y que esfuerzo supone.
No olvides que se trata de java y processing.. pero con una librería al estilo Gemix.
DESCARGA del test: https://www.dropbox.com/s/677jv0cgx3wrf ... 2.rar?dl=0
Source del test:
[Codebox=java file=Untitled.java]int st = 0;
PFont fnt01, fnt02, fnt03, fnt04;
AudioPlayer snd[];
PImage img[];
sprite sp;
boolean guiPosible = true;
sprite b0, b1; // botones del inicio..
//------------------------------------------------------------
void Settings() {
setMode(400, 640, false);
orientation(PORTRAIT);
fps = 60;
fadingColor = 255; // white screen fading..
}
//------------------------------------------------------------
void Setup() {
img = loadImages("images/");
snd = loadSounds("sound/sfx/");
snd[0] = loadSound("sound/music/external.mp3");
fnt01 = loadFont("Lobster1.4-22.vlw");
fnt02 = loadFont("CabinSketch-Bold-48.vlw");
fnt03 = loadFont("DarkCrystalScript-48.vlw");
fnt04 = loadFont("DejaVuSans-48.vlw");
//println(System.getProperty("os.name"));
}
//------------------------------------------------------------
void Draw() {
switch(st) {
case 0:
sp = new gatoIntro();
fadeOff(0);
st = 10;
break;
//++++++++++++++++++++++++++++++++
case 10:
if (fading == false) {
fadeOn(500);
st = 100;
}
break;
//++++++++++++++++++++++++++++++++
case 100:
// el fadeOff() lo hace el proceso del gato..
if(sp.live == false){
fadeOn(250);
//soundPlay(snd[0]);
new scroll(img[10], 0.5, 0);
b0 = new botonSimple(img[7], 200,250,120,150, #F73CF5, "EMPEZAR", 32);
b1 = new botonSimple(img[7], 200,400,120,150, #EDF51B, "SALIR AL SISTEMA", 32);
st = 110;
}
break;
//++++++++++++++++++++++++++++++++
case 110:
screenDrawGraphic(img[7], 200, 50, 0, 180, 200, 128);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 200, 68-22, 0, 255);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 200, 72-22, 0, 255);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 198, 70-22, 0, 255);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 202, 70-22, 0, 255);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 200, 70-22, 255, 255);
screenDrawText(fnt04, 18, "Programado por: Luis Lopez Martinez.", 4, 200, 600, 0,255);
screenDrawText(fnt04, 18, "Idea original: Tabita Jacas Font.", 4, 200, 620, 0,255);
if(b0.z == 1){
fadeOff(500);
st = 120;
}
if(b1.z == 1){exit();}
break;
//++++++++++++++++++++++++++++++++
case 120:
screenDrawGraphic(img[7], 200, 50, 0, 180, 200, 128);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 200, 68-22, 0, 255);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 200, 72-22, 0, 255);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 198, 70-22, 0, 255);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 202, 70-22, 0, 255);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 200, 70-22, 255, 255);
screenDrawText(fnt04, 18, "Programado por: Luis Lopez Martinez.", 4, 200, 600, 0,255);
screenDrawText(fnt04, 18, "Idea original: Tabita Jacas Font.", 4, 200, 620, 0,255);
if(!fading){
letMeAlone();
new SubCrearPartida();
fadeOn(500);
st = 130;
}
break;
//++++++++++++++++++++++++++++++++
case 130:
break;
//++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++
}
}
//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------
class gatoIntro extends sprite{
int st = 0;
int delay;
int anima = 0;
PImage animation[];
int counter = 0;
String t1 = "TAP TAP NYAA!";
void frame(){
switch(st){
//++++++++++++++++++++++++++++++++
case 0:
backgroundColor = color(#090093);
x = 200;
y = 200;
sizeX = 150;
sizeY = 150;
alpha = 0;
animation = loadImages("cat/");
st = 10;
break;
//++++++++++++++++++++++++++++++++
case 10:
delay = (delay + 1) % 8;
if(delay == 0){
anima = (anima+1) % animation.length;
if(anima == 0){
st = 20;
}
}
screenDrawGraphic(animation[anima], x, y, angle, sizeX, sizeY, 255);
// cat sound trigger..
counter ++;
if(counter == 100){
soundPlay(snd[6]);
}
// info text trigger..
if(counter > 130){
if(alpha < 255){
alpha += 5;
}
screenDrawText(fnt01, 42, t1, 4, 200, 370, 255,alpha);
screenDrawText(fnt01, 22, "By Luis lopez & Tabita Jacas", 4, 200, 400, 127,alpha);
}
break;
//++++++++++++++++++++++++++++++++
case 20:
screenDrawGraphic(animation[anima], x, y, angle, sizeX, sizeY, 255);
screenDrawText(fnt01, 42, t1, 4, 200, 370, 255,alpha);
screenDrawText(fnt01, 22, "By Luis lopez & Tabita Jacas", 4, 200, 400, 127,alpha);
fadeOff(1000);
st = 30;
break;
//++++++++++++++++++++++++++++++++
case 30:
screenDrawGraphic(animation[anima], x, y, angle, sizeX, sizeY, 255);
screenDrawText(fnt01, 42, t1, 4, 200, 370, 255,alpha);
screenDrawText(fnt01, 22, "By Luis lopez & Tabita Jacas", 4, 200, 400, 127,alpha);
if(!fading){
signal(id, s_kill);
st = 40;
}
break;
//++++++++++++++++++++++++++++++++
case 40:
break;
//++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++
}
}
}
//------------------------------------------------------------
//------------------------------------------------------------
class scroll extends sprite{
int st = 0;
float w = 400;
float h = 640;
PImage texture = null;
float deltaX = 0;
float deltaY = 0;
//++++++++++++++++++++++++++++++++
//............................
public scroll(PImage texture, float deltaX, float deltaY) {
this.texture = texture;
this.deltaX = deltaX;
this.deltaY = deltaY;
priority = 1024;
}
//............................
//++++++++++++++++++++++++++++++++
void frame(){
// draw scroll..
draw2();
switch(st){
case 0:
x0 += deltaX;
y0 += deltaY;
break;
}
}
//++++++++++++++++++++++++++++++++
void draw2() {
blitter.pushMatrix();
blitter.beginShape();
blitter.textureWrap(REPEAT);
blitter.tint(255, 255);
blitter.texture(texture);
blitter.vertex(x, y, x0, y0);
blitter.vertex(x+w, y, x0+w, y0);
blitter.vertex(x+w, y+h, x0+w, y0+h);
blitter.vertex(x, y+h, x0, y0+h);
blitter.endShape();
blitter.popMatrix();
}
//++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++
}
//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------
class SubCrearPartida extends sprite{
int st = 0;
void frame(){
switch(st){
//............................
case 0:
new scroll(img[11], 0.2, 0.4);
new numeroDeJugadores();
x = 200;
y = 50;
sizeX = 180;
sizeY = 200;
st = 10;
break;
//............................
case 10:
screenDrawGraphic(img[7], x, y, 0, 180, 200, 128);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 200, 68-22, 0, 255);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 200, 72-22, 0, 255);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 198, 70-22, 0, 255);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 202, 70-22, 0, 255);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 200, 70-22, 255, 255);
break;
//............................
case 20:
break;
//............................
//............................
//............................
//............................
}
}
}
//------------------------------------------------------------
class numeroDeJugadores extends sprite{
int st = 0;
sprite b1, b2;
int numPlayers = 2;
//............................
void frame(){
switch(st){
//............................
case 0:
b1 = new botonSimple(img[12], 100, 243, 100, 100, 0, "", 1);
b1.priority = 256;
b2 = new botonSimple(img[12], 300, 243, 100, 100, 0, "", 1);
b2.angle = 180;
b2.priority = 256;
st = 10;
break;
//............................
case 10:
render();
if(b1.z == 1){
if(numPlayers > 2){
numPlayers --;
st = 20;
}
}
if(b2.z == 1){
if(numPlayers < 8){
numPlayers ++;
st = 20;
}
}
break;
//............................
case 20:
render();
if(!mouse.left){
b1.z = 0;
b2.z = 0;
st = 10;
}
break;
//............................
//............................
//............................
//............................
}
}
//............................
void render(){
screenDrawGraphic(img[7], 200, 200, 0, 200, 100, 255);
screenDrawText(fnt02, 32, "CUANTOS JUGADORES?", 4, 200, 196, 255, 255);
screenDrawGraphic(img[8], 200, 240, 0, 100, 100, 255);
screenDrawText(fnt02, 48, str(numPlayers), 4, 200, 240, 255, 255);
}
}
//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------
class botonSimple extends sprite{
int st = 0;
color col = 255;
String texto = "";
int textoSize = 0;
//............................
public botonSimple(PImage g, float x, float y, float sizeX, float sizeY, color col, String texto, int textoSize){
this.x = x;
this.y = y;
this.sizeX = sizeX;
this.sizeY = sizeY;
this.texto = texto;
this.textoSize = textoSize;
this.col = col;
setGraph(g);
}
//............................
void frame(){
switch(st){
//............................
case 0:
st = 10;
break;
//............................
case 10:
screenDrawText(fnt02, textoSize, texto, 4, x, y-5, col, 255);
if(collisionMouse(id)){
if(mouse.left){
z = 1;
}
}
break;
//............................
//............................
}
}
//............................
//............................
//............................
}
//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------[/Codebox]
No olvides que se trata de java y processing.. pero con una librería al estilo Gemix.
DESCARGA del test: https://www.dropbox.com/s/677jv0cgx3wrf ... 2.rar?dl=0
Source del test:
[Codebox=java file=Untitled.java]int st = 0;
PFont fnt01, fnt02, fnt03, fnt04;
AudioPlayer snd[];
PImage img[];
sprite sp;
boolean guiPosible = true;
sprite b0, b1; // botones del inicio..
//------------------------------------------------------------
void Settings() {
setMode(400, 640, false);
orientation(PORTRAIT);
fps = 60;
fadingColor = 255; // white screen fading..
}
//------------------------------------------------------------
void Setup() {
img = loadImages("images/");
snd = loadSounds("sound/sfx/");
snd[0] = loadSound("sound/music/external.mp3");
fnt01 = loadFont("Lobster1.4-22.vlw");
fnt02 = loadFont("CabinSketch-Bold-48.vlw");
fnt03 = loadFont("DarkCrystalScript-48.vlw");
fnt04 = loadFont("DejaVuSans-48.vlw");
//println(System.getProperty("os.name"));
}
//------------------------------------------------------------
void Draw() {
switch(st) {
case 0:
sp = new gatoIntro();
fadeOff(0);
st = 10;
break;
//++++++++++++++++++++++++++++++++
case 10:
if (fading == false) {
fadeOn(500);
st = 100;
}
break;
//++++++++++++++++++++++++++++++++
case 100:
// el fadeOff() lo hace el proceso del gato..
if(sp.live == false){
fadeOn(250);
//soundPlay(snd[0]);
new scroll(img[10], 0.5, 0);
b0 = new botonSimple(img[7], 200,250,120,150, #F73CF5, "EMPEZAR", 32);
b1 = new botonSimple(img[7], 200,400,120,150, #EDF51B, "SALIR AL SISTEMA", 32);
st = 110;
}
break;
//++++++++++++++++++++++++++++++++
case 110:
screenDrawGraphic(img[7], 200, 50, 0, 180, 200, 128);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 200, 68-22, 0, 255);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 200, 72-22, 0, 255);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 198, 70-22, 0, 255);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 202, 70-22, 0, 255);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 200, 70-22, 255, 255);
screenDrawText(fnt04, 18, "Programado por: Luis Lopez Martinez.", 4, 200, 600, 0,255);
screenDrawText(fnt04, 18, "Idea original: Tabita Jacas Font.", 4, 200, 620, 0,255);
if(b0.z == 1){
fadeOff(500);
st = 120;
}
if(b1.z == 1){exit();}
break;
//++++++++++++++++++++++++++++++++
case 120:
screenDrawGraphic(img[7], 200, 50, 0, 180, 200, 128);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 200, 68-22, 0, 255);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 200, 72-22, 0, 255);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 198, 70-22, 0, 255);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 202, 70-22, 0, 255);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 200, 70-22, 255, 255);
screenDrawText(fnt04, 18, "Programado por: Luis Lopez Martinez.", 4, 200, 600, 0,255);
screenDrawText(fnt04, 18, "Idea original: Tabita Jacas Font.", 4, 200, 620, 0,255);
if(!fading){
letMeAlone();
new SubCrearPartida();
fadeOn(500);
st = 130;
}
break;
//++++++++++++++++++++++++++++++++
case 130:
break;
//++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++
}
}
//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------
class gatoIntro extends sprite{
int st = 0;
int delay;
int anima = 0;
PImage animation[];
int counter = 0;
String t1 = "TAP TAP NYAA!";
void frame(){
switch(st){
//++++++++++++++++++++++++++++++++
case 0:
backgroundColor = color(#090093);
x = 200;
y = 200;
sizeX = 150;
sizeY = 150;
alpha = 0;
animation = loadImages("cat/");
st = 10;
break;
//++++++++++++++++++++++++++++++++
case 10:
delay = (delay + 1) % 8;
if(delay == 0){
anima = (anima+1) % animation.length;
if(anima == 0){
st = 20;
}
}
screenDrawGraphic(animation[anima], x, y, angle, sizeX, sizeY, 255);
// cat sound trigger..
counter ++;
if(counter == 100){
soundPlay(snd[6]);
}
// info text trigger..
if(counter > 130){
if(alpha < 255){
alpha += 5;
}
screenDrawText(fnt01, 42, t1, 4, 200, 370, 255,alpha);
screenDrawText(fnt01, 22, "By Luis lopez & Tabita Jacas", 4, 200, 400, 127,alpha);
}
break;
//++++++++++++++++++++++++++++++++
case 20:
screenDrawGraphic(animation[anima], x, y, angle, sizeX, sizeY, 255);
screenDrawText(fnt01, 42, t1, 4, 200, 370, 255,alpha);
screenDrawText(fnt01, 22, "By Luis lopez & Tabita Jacas", 4, 200, 400, 127,alpha);
fadeOff(1000);
st = 30;
break;
//++++++++++++++++++++++++++++++++
case 30:
screenDrawGraphic(animation[anima], x, y, angle, sizeX, sizeY, 255);
screenDrawText(fnt01, 42, t1, 4, 200, 370, 255,alpha);
screenDrawText(fnt01, 22, "By Luis lopez & Tabita Jacas", 4, 200, 400, 127,alpha);
if(!fading){
signal(id, s_kill);
st = 40;
}
break;
//++++++++++++++++++++++++++++++++
case 40:
break;
//++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++
}
}
}
//------------------------------------------------------------
//------------------------------------------------------------
class scroll extends sprite{
int st = 0;
float w = 400;
float h = 640;
PImage texture = null;
float deltaX = 0;
float deltaY = 0;
//++++++++++++++++++++++++++++++++
//............................
public scroll(PImage texture, float deltaX, float deltaY) {
this.texture = texture;
this.deltaX = deltaX;
this.deltaY = deltaY;
priority = 1024;
}
//............................
//++++++++++++++++++++++++++++++++
void frame(){
// draw scroll..
draw2();
switch(st){
case 0:
x0 += deltaX;
y0 += deltaY;
break;
}
}
//++++++++++++++++++++++++++++++++
void draw2() {
blitter.pushMatrix();
blitter.beginShape();
blitter.textureWrap(REPEAT);
blitter.tint(255, 255);
blitter.texture(texture);
blitter.vertex(x, y, x0, y0);
blitter.vertex(x+w, y, x0+w, y0);
blitter.vertex(x+w, y+h, x0+w, y0+h);
blitter.vertex(x, y+h, x0, y0+h);
blitter.endShape();
blitter.popMatrix();
}
//++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++
}
//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------
class SubCrearPartida extends sprite{
int st = 0;
void frame(){
switch(st){
//............................
case 0:
new scroll(img[11], 0.2, 0.4);
new numeroDeJugadores();
x = 200;
y = 50;
sizeX = 180;
sizeY = 200;
st = 10;
break;
//............................
case 10:
screenDrawGraphic(img[7], x, y, 0, 180, 200, 128);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 200, 68-22, 0, 255);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 200, 72-22, 0, 255);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 198, 70-22, 0, 255);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 202, 70-22, 0, 255);
screenDrawText(fnt03, 56, "oCALIMOCHO", 4, 200, 70-22, 255, 255);
break;
//............................
case 20:
break;
//............................
//............................
//............................
//............................
}
}
}
//------------------------------------------------------------
class numeroDeJugadores extends sprite{
int st = 0;
sprite b1, b2;
int numPlayers = 2;
//............................
void frame(){
switch(st){
//............................
case 0:
b1 = new botonSimple(img[12], 100, 243, 100, 100, 0, "", 1);
b1.priority = 256;
b2 = new botonSimple(img[12], 300, 243, 100, 100, 0, "", 1);
b2.angle = 180;
b2.priority = 256;
st = 10;
break;
//............................
case 10:
render();
if(b1.z == 1){
if(numPlayers > 2){
numPlayers --;
st = 20;
}
}
if(b2.z == 1){
if(numPlayers < 8){
numPlayers ++;
st = 20;
}
}
break;
//............................
case 20:
render();
if(!mouse.left){
b1.z = 0;
b2.z = 0;
st = 10;
}
break;
//............................
//............................
//............................
//............................
}
}
//............................
void render(){
screenDrawGraphic(img[7], 200, 200, 0, 200, 100, 255);
screenDrawText(fnt02, 32, "CUANTOS JUGADORES?", 4, 200, 196, 255, 255);
screenDrawGraphic(img[8], 200, 240, 0, 100, 100, 255);
screenDrawText(fnt02, 48, str(numPlayers), 4, 200, 240, 255, 255);
}
}
//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------
class botonSimple extends sprite{
int st = 0;
color col = 255;
String texto = "";
int textoSize = 0;
//............................
public botonSimple(PImage g, float x, float y, float sizeX, float sizeY, color col, String texto, int textoSize){
this.x = x;
this.y = y;
this.sizeX = sizeX;
this.sizeY = sizeY;
this.texto = texto;
this.textoSize = textoSize;
this.col = col;
setGraph(g);
}
//............................
void frame(){
switch(st){
//............................
case 0:
st = 10;
break;
//............................
case 10:
screenDrawText(fnt02, textoSize, texto, 4, x, y-5, col, 255);
if(collisionMouse(id)){
if(mouse.left){
z = 1;
}
}
break;
//............................
//............................
}
}
//............................
//............................
//............................
}
//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------[/Codebox]