need some help for a simple game
in
Programming Questions
•
1 year ago
hey! i am developing my first simple game and have some problems:
1: i want that figure to look left and have his legs on the left side when pressing left button. and the same for the right side.
2: i wanted to stop the eyes and legs like the body does, is there a simple way for it? or do i have to programm it for every single part of that figure?
3: i want the x to cost 1 life and the O to give a point at score, the O and X shall fall in Random positions, and random times, the times they are appearing shall increase with time...
if someone has some advices, pls help ;)
Here the Commands:
1: i want that figure to look left and have his legs on the left side when pressing left button. and the same for the right side.
2: i wanted to stop the eyes and legs like the body does, is there a simple way for it? or do i have to programm it for every single part of that figure?
3: i want the x to cost 1 life and the O to give a point at score, the O and X shall fall in Random positions, and random times, the times they are appearing shall increase with time...
if someone has some advices, pls help ;)
Here the Commands:
- int score = 0;
int life = 3;
float circleX=30, circleY=20;
float circleVY=200;
float linex1=50, liney1=20, linex2=70, liney2=35;
float linex3=50, liney3=35, linex4=70, liney4=20;
float lineVY=200;
float bodyX=300, bodyY=430;
float bodyR=50;
float bodyVX=0, bodySpeed=300;
float legX=315, legY=460;
float legR=30;
float legVX=0, legSpeed=300;
float toeX=285, toeY=460, toeX2=315, toeY2=460;
float toeVX=0, toeSpeed=300;
float eyeX=305, eyeY=423;
float eye2X=280, eye2Y=423;
float eyeVX=0, eyeSpeed=300;
void setup() {
size (640, 480);
}
void keyPressed() {
if (keyCode==LEFT) {
bodyVX = -bodySpeed;
legVX= -legSpeed;
toeVX= -toeSpeed;
eyeVX= -eyeSpeed;
}
else if (keyCode==RIGHT) {
bodyVX = +bodySpeed;
legVX= +legSpeed;
toeVX= +toeSpeed;
eyeVX= +eyeSpeed;
}
}
void keyReleased() {
bodyVX=0;
legVX=0;
toeVX=0;
eyeVX=0;
}
void draw() {
circleY=circleY+circleVY/frameRate;
liney1=liney1+lineVY/frameRate;
liney2=liney2+lineVY/frameRate;
liney3=liney3+lineVY/frameRate;
liney4=liney4+lineVY/frameRate;
bodyX=bodyX+bodyVX/frameRate;
legX=legX+legVX/frameRate;
toeX=toeX+toeVX/frameRate;
toeX2=toeX2+toeVX/frameRate;
eyeX=eyeX+eyeVX/frameRate;
eye2X=eye2X+eyeVX/frameRate;
println("mouseX="+mouseX+" mouseY="+mouseY);
if(bodyX<=25) {
bodyX=25;
bodyVX=0;
}
if(bodyX>=515) {
bodyX=515;
bodyVX=0;
}
//Background
strokeWeight(3);
stroke(0);
rectMode(CENTER);
fill(127,237,131);
rect(320,455,640,50);
fill(255,233,118);
rect(320,215,640,430);
fill(98,251,255);
smooth();
line (540,0,540,480);
//clock
int m = millis();
int seconds = m / 1000;
int minutes = seconds / 60;
int hours = minutes / 60;
int days = hours / 24;
seconds -= minutes * 60;
minutes -= hours * 60;
hours -= days * 24;
String format = "This timer has been running for {0,number,integer} days {1,number,integer} hours {2,number,integer} minutes and {3,number,integer} seconds";
String message = MessageFormat.format(format,
days,
hours,
minutes,
seconds
);
fill (0);
textSize(20);
textAlign (CENTER, TOP);
text (seconds, 600, 0);
text (":",585, 0);
text (minutes, 570, 0);
//Kirby
stroke(0);
fill(98,251,255);
strokeWeight(5);
ellipseMode(CENTER);
ellipse(bodyX,bodyY,bodyR,bodyR);
arc(legX,legY,legR,legR,TWO_PI-PI, TWO_PI);
arc(legX-15,legY,legR,legR,TWO_PI-PI, TWO_PI);
line (toeX,toeY,toeX2,toeY2);
line (toeX+15,toeY,toeX2+15,toeY2);
point (eyeX,eyeY);
point (eyeX+15,eyeY);
//Circle
for (int circleX=30; circleX<520; circleX=circleX+60) {
stroke(0);
fill(31,252,43);
strokeWeight(2);
ellipseMode(CENTER);
ellipse(circleX,circleY,30,30);
}
//X
strokeWeight(5);
stroke(255,0,0);
line(linex1,liney1,linex2,liney2);
line(linex3,liney3,linex4,liney4);
// score
textSize (13);
textAlign (CENTER, TOP);
fill(0);
text("SCORE: ",570,50);
textSize (20);
fill (19,250,34);
text (score, 630, 45);
}
1