Koli's Curse - J2ME Game with problems

Status
Not open for further replies.

zehpavora

Distinguished
Apr 1, 2009
91
0
18,630
Hello.

I have a college game project for J2me - Java Mobile. It's actually in Portuguese now, but I plan on doing the english version in the end (who knows, if I find people to translate it, it can have even more...).

Thing is, it's kinda ready. For those who know programming (I don't do a lot, but oh well...), what I am trying to do is to offload the classes off the main game class. I succeed in parts.

Why? Well, I was able to offload the monster class, and it works, but the image is not being shown, so there's monsters on the screen, but they are invisible. You can hit them, kill them and go to the next stage, but you can't see them at all.

I don't know if I should post the code here, since it's over 1000 lines... But I will anyway so you guys can help me...

MaldicaoKoli.txt - This is the game.

[cpp]
import javax.microedition.lcdui.game.GameCanvas;
import javax.microedition.lcdui.game.Sprite;
import javax.microedition.lcdui.*;
import javax.microedition.rms.*;
import java.io.IOException;

/*
* @author José.Ricardo.Carvalho.Prado.de.Almeida
*/
public class MaldicaoKoli extends GameCanvas implements Runnable {

public MKSetUp midlet;
//
static Sprite superZombies[];
static Sprite zombies[]=new Sprite[6];
Sprite fogofim;
static Sprite protex;
Sprite heroi;
Sprite mira;
Sprite fogo;
//
//
static int contempo = 0;
static int contvidaH = 1600, contvida, zMorteQt, zMorte, hstate;
static int qtdeZumbiM, qtdeSZumbiM, ResultadoSZ, SzMorte, SzMorteQt;
//
int xMira, yMira, contSair;
int contMorte, pstate, tipoZumbi;
int i, cRun, contFogo, tipoProtex;
static int numOndasT, numFase, qtdeZumbi;
int contH, ResultadoZ, qtdeSuperZumbi;
//
int xH = 5, yH = 160;
int xMiraMax = 5, xMiraMax1 = 320;
int yHmin = 142, numOndas = 1, yHmax = 175;
//
static int contaFrameSZ[];
static int contaFrame[];
static int condicaoSZ[];
static int condicao[];
static int c_setSZ[];
static int c_set[];
static int xSZ[];
static int ySZ[];
static int xZ[];
static int yZ[];
static int Sx[];
static int x[];
//
//
boolean rodando = true;
boolean vidaFim, fimVence, vidaFogo, zumbiSet;
static boolean set[], passou[], setSZ[], passouSZ[], fez = false;
//
Zumbis monstro = new Zumbis();
//
String fase;
//
//
int shot = contH = contFogo = ResultadoZ = 0;
int contH1 = i = hstate = contMorte = pstate = contSair = 0;
int contaTiro = qtdeZumbiM = qtdeSZumbiM = ResultadoSZ = zMorte = SzMorte = zMorteQt = SzMorteQt = 0;
//
boolean fim = vidaFim = fimVence = vidaFogo = zumbiSet = false;
//
//
Graphics g = getGraphics();

public MaldicaoKoli(MKSetUp midlet) {
super(true);
this.midlet = midlet;
}

public void run() {

setFullScreenMode(true);
contaFrameSZ = new int[qtdeZumbi];

contaFrame = new int[qtdeZumbi];
condicaoSZ = new int[qtdeZumbi];
condicao = new int[qtdeZumbi];
c_setSZ = new int[qtdeZumbi];
c_set = new int[qtdeZumbi];
xSZ = new int[qtdeZumbi];
ySZ = new int[qtdeZumbi];
xZ = new int[qtdeZumbi];
yZ = new int[qtdeZumbi];
Sx = new int[qtdeZumbi];
x = new int[qtdeZumbi];
set = new boolean[qtdeZumbi];
passou = new boolean[qtdeZumbi];

Image fundo = carregar_img("/BackGround.png");
Image chao = carregar_img("/Chao.png");
Image stats = carregar_img("/Status.png");
Image gameover = carregar_img("/GameOver.png");
Image gamewon = carregar_img("/GameWon.png");

Image zumbi = carregar_img("/zumbi.png");
for (i = 0; i < qtdeZumbi; i++) {
zombies = new Sprite(zumbi, 48, 48);
}

Image target = carregar_img("/mira.png");
mira = new Sprite(target, 12, 12);

Image hero = carregar_img("/hero.png");
heroi = new Sprite(hero, 48, 48);

Image torre = carregar_img("/carro.png");
protex = new Sprite(torre, 52, 48);

Image fire = carregar_img("/Fogo.png");
fogo = new Sprite(fire, 48, 48);

Image firefim = carregar_img("/FogoFim.png");
fogofim = new Sprite(firefim, 55, 52);

protex.setPosition(20, 50);
protex.paint(g);

xMira = 66;
yMira = 162;

while (rodando) {

if ((fim == false) && (fimVence == false)) {
verificarTeclas();
}

g.drawImage(fundo, 0, 0, 0);
g.drawImage(chao, 0, 190, 0);
g.drawImage(stats, 0, 217, 0);

g.setColor(255, 255, 255);
g.drawString(zMorteQt + "/" + qtdeZumbi, 265, 225, 0);
g.drawString(numOndas + "/" + numOndasT, 195, 225, 0);
g.drawString("" + numFase, 152, 225, 0);

desenharHeroi();

desenharProtecao();
if (qtdeZumbi != 0) {
monstro.desenharZombie(qtdeZumbi);
}

if (zMorte == qtdeZumbi) {
hstate = 5;
zMorte = 0;
}

if (qtdeSuperZumbi != 0) {
monstro.desenharSuperZombie(i, qtdeSuperZumbi);
//}
if (SzMorte == superZombies.length) {
hstate = 5;
SzMorte = 0;
}
}

desenharVida();

desenharVidaH();

mira.setPosition(xMira, yMira);
mira.paint(g);

if (fim == true) {
g.drawImage(gameover, 160, 120, Graphics.HCENTER | Graphics.VCENTER);
if (contSair < 6) {
contSair++;
} else if (contSair == 6) {

contSair = 0;
calculaRecorde(contvidaH, contvida, qtdeZumbiM, qtdeSZumbiM, contaTiro);
}

} else if (fimVence == true) {
g.drawImage(gamewon, 160, 120, Graphics.HCENTER | Graphics.VCENTER);
if (contSair < 6) {
contSair++;
} else if (contSair == 6) {

contSair = 0;
calculaRecorde(contvidaH, contvida, qtdeZumbiM, qtdeSZumbiM, contaTiro);
}
}

flushGraphics();

try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
}
}

public void iniciar() {
Thread t = new Thread(this);
t.start();
}

public static Image carregar_img(String nomeArquivo) {
try {

Image img = Image.createImage(nomeArquivo);
return img;

} catch (IOException e) {
return null;
}
}

public void desenharHeroi() {

int hrun[] = {19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29};
int hdie[] = {30, 31, 32, 33, 34, 35, 36, 37, 38};
int hwalk[] = {7, 8, 9, 10, 11, 12};
int hprerun[] = {16, 17, 18};
int hmove[] = {2, 3, 4, 5};
int hattack[] = {0};
int hnull[] = {38};
int hstop[] = {1};
//
if (yH < yHmin) {
yH += 6;
} else if (yH > yHmax) {
yH -= 6;
}

heroi.setPosition(xH, yH);

switch (hstate) {
case 0:
heroi.setFrameSequence(hstop);
break;

case 1:
heroi.setFrameSequence(hattack);
hstate = 0;
break;

case 2:
if (contH >= 1) {
heroi.setFrameSequence(hmove);
contH = 0;
}

contH1++;

if (contH1 == 4) {
heroi.setFrameSequence(hattack);
contH1 = 0;
}
break;

case 3:
heroi.setFrameSequence(hdie);
hstate = 4;
break;

case 4:
if (contMorte < 7) {
contMorte++;

} else if (contMorte >= 7) {
heroi.setFrameSequence(hnull);
contMorte = 0;
fim = true;
}
break;

case 5:
heroi.setFrameSequence(hprerun);
hstate = 6;
break;

case 6:
if (cRun < 3) {
cRun++;
xH += 5;
} else if (cRun >= 3) {
heroi.setFrameSequence(hrun);
hstate = 7;
}
break;

case 7:
xH += 15;
if (xH > 320) {
fimVence = true;
}
break;
}

heroi.nextFrame();
heroi.paint(g);
}

public void desenharProtecao() {

int fire1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
int fire2[] = {12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
int firefinal[] = {0, 1, 2, 3, 4, 5};
int fireNull[] = {5};

protex.setPosition(45, 160);
protex.paint(g);

if (contvida <= 400) {

if ((protex.isVisible() == false) && (vidaFogo == false)) {

fogo.setVisible(false);
fogofim.setPosition(45, 160);

switch (pstate) {
case 0:
pstate = 1;
fogofim.setFrameSequence(firefinal);
break;

case 1:
if (contFogo < 6) {
contFogo++;
} else if (contFogo == 6) {
contFogo = 0;
}
pstate = 2;
break;

case 2:
fogofim.setFrameSequence(fireNull);
fogofim.setVisible(false);
vidaFogo = true;
break;
}

fogofim.nextFrame();
fogofim.paint(g);

} else if (vidaFogo == false) {
fogo.setPosition(45, 140);

if (contFogo <= 14) {
contFogo++;

} else if (contFogo == 14) {
fogo.setFrameSequence(fire2);
contFogo++;

} else if ((contFogo >= 15) && (contFogo <= 29)) {
contFogo++;

} else if (contFogo > 29) {
fogo.setFrameSequence(fire1);
contFogo = 0;
}

fogo.nextFrame();
fogo.paint(g);
}
}
}

public void verificarTeclas() {
int teclas = getKeyStates();

if ((teclas & GameCanvas.LEFT_PRESSED) != 0) {
xMira -= 6;
}

if ((teclas & GameCanvas.RIGHT_PRESSED) != 0) {
xMira += 6;
}

if ((teclas & GameCanvas.UP_PRESSED) != 0) {
yMira -= 6;
hstate = 2;
contH = 1;
yH -= 6;
}

if ((teclas & GameCanvas.DOWN_PRESSED) != 0) {
yMira += 6;
hstate = 2;
contH = 1;
yH += 6;
}

if ((teclas & GameCanvas.FIRE_PRESSED) != 0) {

contaTiro++;
if (qtdeZumbi != 0) {
if ((xMira >= xMiraMax) && (xMira <= xMiraMax1)) {
if ((mira.collidesWith(Zumbis.zombies[0], true)) == true) {
shot++;
contaTiro -= 3;
if (shot == 3) {
Zumbis.condicao[0] = 4;
shot = 0;
}
hstate = 1;
}

if ((mira.collidesWith(Zumbis.zombies[1], true)) == true) {
shot++;
if (shot == 3) {
Zumbis.condicao[1] = 4;
shot = 0;
}
hstate = 1;
}
try {
if ((mira.collidesWith(Zumbis.zombies[2], true)) == true) {
shot++;
if (shot == 3) {
Zumbis.condicao[2] = 4;
shot = 0;
}
hstate = 1;
}

if ((mira.collidesWith(Zumbis.zombies[3], true)) == true) {
shot++;
if (shot == 3) {
Zumbis.condicao[3] = 4;
shot = 0;
}
hstate = 1;
}
} catch (Exception e) {
}
try {
if ((mira.collidesWith(Zumbis.zombies[4], true)) == true) {
shot++;
if (shot == 3) {
Zumbis.condicao[4] = 4;
shot = 0;
}
hstate = 1;
}

if ((mira.collidesWith(Zumbis.zombies[5], true)) == true) {
shot++;
if (shot == 3) {
Zumbis.condicao[5] = 4;
shot = 0;
}
hstate = 1;
}
} catch (Exception e) {
}
}

if (qtdeSuperZumbi != 0) {
try {
if ((mira.collidesWith(Zumbis.superZombies[0], true)) == true) {
shot++;
contaTiro -= 3;
if (shot == 3) {
Zumbis.condicaoSZ[0] = 4;
shot = 0;
}
hstate = 1;
}
if ((mira.collidesWith(Zumbis.superZombies[1], true)) == true) {
shot++;
if (shot == 3) {
Zumbis.condicaoSZ[1] = 4;
shot = 0;
}
hstate = 1;
}

if ((mira.collidesWith(Zumbis.superZombies[2], true)) == true) {
shot++;
if (shot == 3) {
Zumbis.condicaoSZ[2] = 4;
shot = 0;
}
hstate = 1;
}

if ((mira.collidesWith(Zumbis.superZombies[3], true)) == true) {
shot++;
if (shot == 3) {
Zumbis.condicaoSZ[3] = 4;
shot = 0;
}
hstate = 1;
}
if ((mira.collidesWith(Zumbis.superZombies[4], true)) == true) {
shot++;
if (shot == 3) {
Zumbis.condicaoSZ[4] = 4;
shot = 0;
}
hstate = 1;
}

if ((mira.collidesWith(Zumbis.superZombies[5], true)) == true) {
shot++;
if (shot == 3) {
Zumbis.condicaoSZ[5] = 4;
shot = 0;
}
hstate = 1;
}
} catch (Exception e) {
}
}
}
}
}

public void desenharVida() {

g.setColor(0, 0, 0);
g.drawRect(88, 230, (400 * 39 / 500) + 1, 5);

g.setColor(255, 0, 0);
g.fillRect(89, 231, ((contvida / 4) * 39 / 500), 5);

if (contvida <= 0) {
g.setColor(255, 255, 0);
protex.setVisible(false);
}
}

public void desenharVidaH() {

g.setColor(0, 0, 0);
g.drawRect(45, 230, (400 * 39 / 500) + 1, 5);

g.setColor(0, 255, 0);
g.fillRect(46, 231, ((contvidaH / 4) * 39 / 500), 5);

if (contvidaH <= 0) {
g.setColor(255, 255, 0);
if (vidaFim == false) {
hstate = 3;
vidaFim = true;
}
}
}

public void calculaRecorde(int vidaH, int vidaP, int numeroZM, int numeroSZM, int tiroD) {
int Resultado = 0;
calcRecord score = new calcRecord();
tiroD = tiroD - (3 * numeroZM);

if (qtdeZumbi != 0) {
ResultadoZ = (vidaH / 16) + (vidaP / 16) + (numeroZM / qtdeZumbi) - tiroD;
}

if (qtdeSuperZumbi != 0) {
ResultadoSZ = (vidaH / 16) + (vidaP / 16) + (numeroSZM / qtdeSuperZumbi) - tiroD;
}

Resultado = ResultadoZ + ResultadoSZ;

score.gravaRecorde(Resultado);
Sair();
}

public void Reset() {

try {

RecordStore rs = RecordStore.openRecordStore(MKSetUp.Fase, true);
String temp = new String(rs.getRecord(1));

if (temp.equals("A")) {
contvida = 1600;
numOndasT = 1;
numFase = 1;
qtdeZumbi = 2;
// chefe Zumbi Agua

} else if (temp.equals("B")) {
contvida = 1600;
numOndasT = 1;
numFase = 1;
qtdeZumbi = 2;
// chefe Acheman

} else if (temp.equals("C")) {
contvida = 1600;
numOndasT = 1;
numFase = 1;
qtdeZumbi = 2;
// chefe Wraith+Magic
} else {

switch (temp.charAt(0)) {

case '0':
contvida = 1600;
numOndasT = 1;
numFase = 1;
qtdeZumbi = 2;
// 1 onda, 2 zumbis, zumbi normal
break;

case '1':
contvida = 1600;
numOndasT = 1;
numFase = 2;
qtdeZumbi = 4;
// 1 onda, 4 zumbis, zumbi normal
break;

case '2':
contvida = 1600;
numOndasT = 1;
numFase = 3;
qtdeZumbi = 6;
// 1 onda, 6 zumbis, zumbi normal
break;

case '3':
contvida = 1600;
numOndasT = 2;
numFase = 4;
qtdeZumbi = 6;
// 2 ondas, 6 zumbis, zumbi normal
break;

case '4':
contvida = 1600;
numOndasT = 3;
numFase = 5;
qtdeSuperZumbi = 6;
// 3 ondas, 6 zumbis, super zumbi
break;

case '5':
contvida = 1600;
numOndasT = 4;
numFase = 6;
qtdeSuperZumbi = 6;
// 4 ondas, 6 zumbis, super zumbi
break;

case '6':
contvida = 1600;
numOndasT = 5;
numFase = 7;
qtdeSuperZumbi = 6;
// 5 ondas, 6 zumbis, super zumbi
break;

case '7':
contvida = 1600;
numOndasT = 6;
numFase = 8;
qtdeSuperZumbi = 6;
// 6 ondas, 6 zumbis, super zumbi
break;

case '8':
contvida = 1600;
numOndasT = 7;
numFase = 9;
qtdeSuperZumbi = 6;
// 7 ondas, 6 zumbis, super zumbi
break;
}
}
} catch (Exception e) {
}

yH = 160;
xMiraMax1 = 320;
xH = xMiraMax = 5;
yHmin = 142;
yHmax = 170;
contvidaH = 1600;

contaTiro = qtdeZumbiM = 0;
contempo = shot = contH = contFogo = ResultadoZ = zMorteQt = 0;
contH1 = i = hstate = contMorte = pstate = contSair = zMorte = 0;

fim = vidaFim = fimVence = vidaFogo = false;

rodando = true;
iniciar();
}

public void Sair() {

try {

RecordStore rs = RecordStore.openRecordStore(MKSetUp.Fase, true);
if (fim == true) {

fase = "0";
rs.setRecord(1, fase.getBytes(), 0, fase.getBytes().length);

} else if (fimVence == true) {
String temp = new String(rs.getRecord(1));

if (temp.equals("A")) {

fase = "3";
rs.setRecord(1, fase.getBytes(), 0, fase.getBytes().length);

} else if (temp.equals("B")) {

fase = "6";
rs.setRecord(1, fase.getBytes(), 0, fase.getBytes().length);

} else if (temp.equals("C")) {

fase = "0";
rs.setRecord(1, fase.getBytes(), 0, fase.getBytes().length);
} else {

switch (temp.charAt(0)) {

case '0':
fase = "1";
rs.setRecord(1, fase.getBytes(), 0, fase.getBytes().length);
break;

case '1':
fase = "2";
rs.setRecord(1, fase.getBytes(), 0, fase.getBytes().length);
break;

case '2':
fase = "A";
rs.setRecord(1, fase.getBytes(), 0, fase.getBytes().length);
break;

case '3':
fase = "4";
rs.setRecord(1, fase.getBytes(), 0, fase.getBytes().length);
break;

case '4':
fase = "5";
rs.setRecord(1, fase.getBytes(), 0, fase.getBytes().length);
break;

case '5':
fase = "B";
rs.setRecord(1, fase.getBytes(), 0, fase.getBytes().length);
break;

case '6':
fase = "7";
rs.setRecord(1, fase.getBytes(), 0, fase.getBytes().length);
break;

case '7':
fase = "8";
rs.setRecord(1, fase.getBytes(), 0, fase.getBytes().length);
break;

case '8':
fase = "C";
rs.setRecord(1, fase.getBytes(), 0, fase.getBytes().length);
break;
}
}
}
} catch (Exception e) {
}

rodando = false;
MenuRecord.funfar = true;
midlet.recordesShow();
}
}
[/cpp]



Zumbis.txt - This is the monster class.

[cpp]
import java.io.IOException;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.*;

/**
*
* @author jose.prado
*
*/
public class Zumbis extends GameCanvas {
//

static int i;
Image zumbi = carregar_img("/zumbi.png");
static int contvidaH = 1600;
static int hstate = MaldicaoKoli.hstate;
static int contvida = MaldicaoKoli.contvida;
static int contempo = MaldicaoKoli.contempo;
static boolean setUpZ;
static int condicao[];
static int condicaoSZ[];
//
static Sprite zombies[] = MaldicaoKoli.zombies;
static Sprite superZombies[];
static Sprite protex = MaldicaoKoli.protex;
Graphics g = getGraphics();
int qtdeSuperZumbi;

public Zumbis() {
super(true);
}

public void desenharZombie(int qtdeZumbi) {

if (MaldicaoKoli.fez == false) {
for (i = 0; i < 6; i++) {
zombies = new Sprite(MaldicaoKoli.carregar_img("/zumbi.png"), 48, 48);
}
MaldicaoKoli.fez=true;
}
//
int j;
int zMorte = MaldicaoKoli.zMorte;
int zMorteQt = MaldicaoKoli.zMorteQt;
int qtdeZumbiM = MaldicaoKoli.qtdeZumbiM;
//
//
int x[] = MaldicaoKoli.x;
int xZ[] = MaldicaoKoli.xZ;
int yZ[] = MaldicaoKoli.yZ;
int c_set[] = MaldicaoKoli.c_set;
int contaFrame[] = MaldicaoKoli.contaFrame;

condicao = MaldicaoKoli.condicao;
//
boolean set[] = MaldicaoKoli.set;
boolean passou[] = MaldicaoKoli.passou;
//

if (setUpZ == false) {

for (j = 0; j < qtdeZumbi; j++) {

try {
zombies[j] = new Sprite(MaldicaoKoli.carregar_img("/zumbi.png"), 48, 48);
} catch (Exception e) {
}

condicao[j] = 0;
x[j] = 285;
yZ[j] = 160;
set[j] = false;
}

setUpZ = true;
}

for (i = 0; i < qtdeZumbi; i++) {

//i = cont;

for (j = 0; j < qtdeZumbi; j++) {
xZ[j] = x[j];
}

if (set == false) {
if (c_set < 2) {
c_set++;
} else {
set = true;
}
}

int zdie[] = {7, 8, 9, 10, 11, 12, 13};
int zattack[] = {0, 1, 2, 3, 4, 5, 6};
int zborn[] = {14, 15, 16, 17, 18, 6};
int zwalk[] = {0, 1, 2, 3, 4, 5, 6};
int znull[] = {19};
int zstop[] = {6};

//

if (hstate >= 3) {
zombies.setFrameSequence(zstop);
}

try {
zombies[0].setPosition(xZ[0], yZ[0]);
} catch (Exception e) {
}

try {
zombies[1].setPosition(xZ[1] - 20, yZ[1]);
} catch (Exception e) {
}

if (qtdeZumbi > 2) {
try {
zombies[2].setPosition(xZ[2] - 5, yZ[0]);
zombies[3].setPosition(xZ[3] - 25, yZ[1]);
zombies[4].setPosition(xZ[4] - 10, yZ[0]);
zombies[5].setPosition(xZ[5] - 30, yZ[1]);
} catch (Exception e) {
}
}

switch (condicao) {
case 0:
zombies.setFrameSequence(zborn);
condicao = 1;
break;

case 1:
if (contaFrame < 4) {
contaFrame++;
} else if (contaFrame == 4) {
contaFrame = 0;
zombies.setFrameSequence(zwalk);
condicao = 2;
}
break;

case 2:
if (xZ[0] <= 80) {
zombies[0].setFrameSequence(zattack);
condicao[0] = 3;
} else {
xZ[0] -= 1;
x[0] = xZ[0];
MaldicaoKoli.x[0] = x[0];
}

if (xZ[1] <= 100) {
zombies[1].setFrameSequence(zattack);
condicao[1] = 3;
} else {
xZ[1] -= 1;
x[1] = xZ[1];
MaldicaoKoli.x[1] = x[1];
}

if (zombies.length > 2) {
try {
if (xZ[2] <= 85) {
zombies[2].setFrameSequence(zattack);
condicao[2] = 3;
} else {
xZ[2] -= 1;
x[2] = xZ[2];
MaldicaoKoli.x[2] = x[2];
}

if (xZ[3] <= 105) {
zombies[3].setFrameSequence(zattack);
condicao[3] = 3;
} else {
xZ[3] -= 1;
x[3] = xZ[3];
MaldicaoKoli.x[3] = x[3];
}
if (xZ[4] <= 85) {
zombies[4].setFrameSequence(zattack);
condicao[4] = 3;
} else {
xZ[4] -= 1;
x[4] = xZ[4];
MaldicaoKoli.x[4] = x[4];
}

if (xZ[5] <= 105) {
zombies[5].setFrameSequence(zattack);
condicao[5] = 3;
} else {
xZ[5] -= 1;
x[5] = xZ[5];
MaldicaoKoli.x[5] = x[5];
}

} catch (Exception e) {
}
}
break;

case 3:
if (contempo < 10) {
contempo++;
} else if (contempo >= 10) {
contvida -= 300;
contempo = 0;

MaldicaoKoli.contvida = contvida;
}
break;

case 4:
zombies.setFrameSequence(zdie);
qtdeZumbiM++;
condicao = 5;
MaldicaoKoli.qtdeZumbiM = qtdeZumbiM;
break;

case 5:
if (contaFrame < 5) {
contaFrame++;
} else if (contaFrame >= 5) {
contaFrame = 0;
zombies.setFrameSequence(znull);
xZ = 285;
x = xZ;
zMorte++;
zMorteQt++;
condicao = 8;

MaldicaoKoli.x = x;
MaldicaoKoli.zMorte = zMorte;
MaldicaoKoli.zMorteQt = zMorteQt;
}
break;

case 6:
if (xZ <= 27) {
condicao = 7;
contempo = 0;
} else {
xZ -= 5;
x = xZ;
MaldicaoKoli.x = x;
}
break;

case 7:
if (contempo < 10) {
contempo++;
} else if (contempo >= 10) {
contvidaH -= 300;
contempo = 0;

MaldicaoKoli.contvidaH = contvidaH;
}
break;

case 8:
zombies.setFrameSequence(znull);
break;
}

if ((MaldicaoKoli.protex.isVisible() == false) && (passou == false)) {
condicao = 6;
passou = true;
}
zombies.nextFrame();
zombies.paint(g);

MaldicaoKoli.zMorte = zMorte;
MaldicaoKoli.zMorteQt = zMorteQt;
MaldicaoKoli.qtdeZumbiM = qtdeZumbiM;
//
//
MaldicaoKoli.xZ = xZ;
MaldicaoKoli.yZ = yZ;
MaldicaoKoli.c_set = c_set;
MaldicaoKoli.condicao = condicao;
MaldicaoKoli.contaFrame = contaFrame;
//
MaldicaoKoli.set = set;
MaldicaoKoli.passou = passou;
}
}

public void desenharSuperZombie(int cont, int qtdeSuperZumbi) {

boolean setUpSZ = false;
int SzMorte = MaldicaoKoli.SzMorte;
int SzMorteQt = MaldicaoKoli.SzMorteQt;
int qtdeSZumbiM = MaldicaoKoli.qtdeSZumbiM;
//
//
int Sx[] = new int[qtdeSuperZumbi];
int xSZ[] = new int[qtdeSuperZumbi];
int ySZ[] = new int[qtdeSuperZumbi];
int c_setSZ[] = new int[qtdeSuperZumbi];
condicaoSZ = new int[qtdeSuperZumbi];
int contaFrameSZ[] = new int[qtdeSuperZumbi];
//
boolean setSZ[] = new boolean[qtdeSuperZumbi];
boolean passouSZ[] = new boolean[qtdeSuperZumbi];
//
superZombies = new Sprite[qtdeSuperZumbi];

if (setUpSZ == false) {
for (i = 0; i < superZombies.length; i++) {
superZombies = new Sprite(MaldicaoKoli.carregar_img("/zumbi.png"), 48, 48);
condicaoSZ = 0;
Sx = 285;

for (i = 0; i < ySZ.length; i++) {
ySZ = 160;
setSZ = false;
}
}
setUpSZ = true;
}

i = cont;

//for (i = 0; i < qtdeSuperZumbi; i++) {

xSZ = Sx;

if (setSZ == false) {
if (c_setSZ < 2) {
c_setSZ++;
} else {
setSZ = true;
}
}

int Szdie[] = {0};
int Szattack[] = {7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23};
int Szborn[] = {0};
int Szwalk[] = {1, 2, 3, 4, 5, 6};
int Sznull[] = {0};
int Szstop[] = {0};

//

if (hstate >= 3) {
superZombies.setFrameSequence(Szstop);
}

superZombies[0].setPosition(xSZ[0], ySZ[0]);
superZombies[1].setPosition(xSZ[1] - 20, ySZ[1]);

if (superZombies.length == 4) {
try {
superZombies[2].setPosition(xSZ[2] - 5, ySZ[0]);
superZombies[3].setPosition(xSZ[3] - 25, ySZ[1]);
} catch (Exception e) {
}
try {
superZombies[4].setPosition(xSZ[4] - 10, ySZ[0] + 5);
superZombies[5].setPosition(xSZ[5] - 30, ySZ[1] + 10);
} catch (Exception e) {
}
}

switch (condicaoSZ) {
case 0:
superZombies.setFrameSequence(Szborn);
condicaoSZ = 1;
break;

case 1:
if (contaFrameSZ < 4) {
contaFrameSZ++;
} else if (contaFrameSZ == 4) {
contaFrameSZ = 0;
superZombies.setFrameSequence(Szwalk);
condicaoSZ = 2;
}
break;

case 2:
if (xSZ[0] <= 80) {
superZombies[0].setFrameSequence(Szattack);
condicaoSZ[0] = 3;
} else {
xSZ[0] -= 1;
Sx[0] = xSZ[0];
}

if (xSZ[1] <= 100) {
superZombies[1].setFrameSequence(Szattack);
condicaoSZ[1] = 3;
} else {
xSZ[1] -= 1;
Sx[1] = xSZ[1];
}

if (superZombies.length == 4) {
try {
if (xSZ[2] <= 85) {
superZombies[2].setFrameSequence(Szattack);
condicaoSZ[2] = 3;
} else {
xSZ[2] -= 1;
Sx[2] = xSZ[2];
}

if (xSZ[3] <= 105) {
superZombies[3].setFrameSequence(Szattack);
condicaoSZ[3] = 3;
} else {
xSZ[3] -= 1;
Sx[3] = xSZ[3];
}

} catch (Exception e) {
}
}
break;

case 3:
if (contempo < 10) {
contempo++;
} else if (contempo >= 10) {
contvida -= 300;
contempo = 0;

MaldicaoKoli.contvida = contvida;
}
break;

case 4:
superZombies.setFrameSequence(Szdie);
qtdeSZumbiM++;
condicaoSZ = 5;

MaldicaoKoli.qtdeSZumbiM = qtdeSZumbiM;
break;

case 5:
if (contaFrameSZ < 5) {
contaFrameSZ++;
} else if (contaFrameSZ >= 5) {
contaFrameSZ = 0;
superZombies.setFrameSequence(Sznull);
xSZ = 285;
Sx = xSZ;
SzMorte++;
SzMorteQt++;
condicaoSZ = 8;

MaldicaoKoli.SzMorte = SzMorte;
MaldicaoKoli.SzMorteQt = SzMorteQt;
}
break;

case 6:
if (xSZ <= 27) {
condicaoSZ = 7;
contempo = 0;
} else {
xSZ -= 5;
Sx = xSZ;
}
break;

case 7:
if (contempo < 10) {
contempo++;
} else if (contempo >= 10) {
contvidaH -= 300;
contempo = 0;

MaldicaoKoli.contvidaH = contvidaH;
}
break;

case 8:
superZombies.setFrameSequence(Sznull);
break;
}

if ((protex.isVisible() == false) && (passouSZ == false)) {
condicaoSZ = 6;
passouSZ = true;
}

superZombies.nextFrame();
superZombies.paint(g);

//}
}

public static Image carregar_img(String nomeArquivo) {
try {
Image img = Image.createImage(nomeArquivo);
return img;
} catch (IOException e) {
return null;
}
}
}
[/cpp]


If you look at the code, you'll see that I'm not posting all the classes in the game. Simply because they're not needed to run the game (actually, they are, but there's no problem with them). If you think I should put them here too, tell me, OK?

Also, I would like to kindly ask anyone who download my code(s) NOT to do anything with it unless I say so. This was made by scratch by me, so I own it.

Thanks, all.
 

kyeana

Distinguished
May 21, 2008
1,290
0
19,310
I am assuming that those object names, etc are in Portuguese? That, coupled with the fact that there are no comments or method headers in any of the code would make it a right pain in the arse to go through and understand all of this code...

Some general advice I could think of right off hand is:
1. Are you sure the picture files are in the correct directory? (could you try using a full link to the picture to insure this works?)
2. Have you used a debugger to step through the code that is supposed to display the picture? Any info on what is happening there?
 

zehpavora

Distinguished
Apr 1, 2009
91
0
18,630
Forget the help guys!

I was able to do it on my own. It was just a matter of returning the sprite to the game and make the game change the frames and paint the sprite.

I'm am now trying to make this game a little more object oriented, since it is Java-based anyway.

Thanks for trying, and I'm sorry I couldn't ask in a better way.
 
Status
Not open for further replies.