We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Help in my first game (shooting with the ship).
Hello, Goodnight everyone! My name is Gabriel Almeida, I am Brazilian and I started my studies in game design a short time, when my initial focus will be on schedule, I started to try a little game of spacecraft today in processing language and am having difficulties with the shot ship. Remembering that I am using google translate to communicate and do not know if I published the question in the correct section of the forum, if in the wrong section please move my question to the appropriate place =) The code I've written so far is as follows:
int vidaNave= 3; int pxnave; int pynave; int posx= 400; int posy= 300; PImage nave; PImage tiro_1; PImage efeito_tiro; PImage vidaNave1; PImage vidaNave2; PImage vidaNave3; int tiroy; boolean delay=true; int b; int c;
void setup() { size(800, 600); background(200, 200, 200); nave = loadImage("nave1.png"); tiro_1 = loadImage("tiro1.png"); efeito_tiro = loadImage("efeitotiro.png"); }
void draw() { background(200, 200, 200); image(nave, posx, posy); frameRate(60); movimento(); tiro();
}
void tiro(){
tiroy-=0; if(key == 'l' || key == 'L'){ int y=posy; image(tiro_1,posx+40,y+tiroy-5+(b-=5)); image(efeito_tiro,posx+30,posy); c = (y+tiroy+(b-=5)); }
}
void movimento() { int d=posx+40; if (keyPressed) { if (key == 'a' || key == 'A') { image(tiro_1,d,c); c-=5; posx -=10; if (posx<0) { posx +=10; } } if (key == 'd' || key == 'D') { image(tiro_1,d,c); c-=5; posx =posx+10; if (posx>700) { posx -=10; } } if (key == 'w' || key == 'W') { image(tiro_1,d,c); c-=5; posy-=5; if (posy<0) { posy+=5; } } if (key == 's' || key == 'S') { image(tiro_1,d,c);
posy+=5;
if (posy>500) {
posy-=5;
}
}
} }
void vida_nave() {
}
"Sorry, not yet picked up the habit of using comments"
I would like to processing programming book recommendations aimed at games (in the case in the English language because I did not think in Portuguese), aid in relation to the method "shot" of my schedule and if possible a code that would make a shooting missiles using arrays (I'm still learning how to use arrays in processing) that is equal to this video:
The author does not teach how to make this shot using arrays but advises that easy.
I thank the attention =)
Answers
http://forum.processing.org/two/discussion/8045/how-to-format-code-and-text
for the organization of your code:
you want to show the ship tiro all the time, so call tiro in draw() but use
image()
outside any if-clauseinstead of
you want
(these lines for the key can also be in
movimento()
)in movimento()
also in
movimento()
: no need to have(it's in
draw()
already)for shooting
for shooting see
http://www.openprocessing.org/sketch/77863
Best, Chrisir ;-)