i want to make a class of circles, they shall look the same. but i want them to have different speed and when they leave the screen border, they shall start to move from a random position, and they shall just move on the y coordinates ( sry for my bad english. )
i would like to have an example with 2 circles so i could understand it better.
Hey guys i have to programm a game till the next 4 hours and i need help with the final step:
i want the score to get 1 up if the Kirby hits the circle but i dont get it to that point -.-
here is the game if you urn it, you wil understand how it shall work, pls tell how i have to write the if sentence!
//Tunnellänge & -breite float tubeLength=100000, tubeWidth= 230; //Position des Tunnel float screenLeftY = 0; float health; float initialHealth = 500; //Form, Geschwindigkeit und Position der Figur float bodyX, bodyY; float bodyR=50; float bodyVX, speed; float bodyVY; float legX, legY; float legR; float legVX; float legVY; float toeX, toeY, toeX2, toeY2; float toeVX; float toeVY; float eyeX, eyeY; float eyeVX; float eyeVY; //Variablen für den Kreis float circleX, circleY; float circleR=30; float circleVY=100; int score = 0; // Variablen die den verschiedenen Spielestatus beschreiben. int GAMEWAIT=0, GAMERUNNING=1, GAMEOVER=2, GAMEWON=3; int gameState=GAMEWAIT;
void draw() { //Wenn das Spiel läuft, starten die Bewegungen if (gameState==GAMERUNNING) { bodyX = bodyX + bodyVX/frameRate; bodyY = bodyY + bodyVY/frameRate; legX=legX+legVX/frameRate; toeX=toeX+toeVX/frameRate; toeX2=toeX2+toeVX/frameRate; eyeX=eyeX+eyeVX/frameRate; legY=legY+legVY/frameRate; toeY=toeY+toeVY/frameRate; toeY2=toeY2+toeVY/frameRate; eyeY=eyeY+eyeVY/frameRate; circleY=circleY-circleVY/frameRate; screenLeftY = bodyY-50;
// Kirby darf den Tunnel nicht verlassen { float x=0.9*width*noise (bodyY/width); if (bodyX-25<=x || bodyX+25>=x+tubeWidth) {health-=20; bodyX=x+tubeWidth/2; legX=bodyX+15; toeX=bodyX-15; toeX2=bodyX+15; eyeX=bodyX+5; } //Wenn ein Kreis außerhalb des Tunnels generiert wird, soll ihm eine neue Position zugewiesen werden. if (circleX-15<=x || circleX+15>=x+tubeWidth){ circleX = 0.9*height*noise (0)+tubeWidth*random(0,3); }
//HERE I NEED HELP: // Wenn Kirby einen Kreis erwischt, soll sich Score um 1 erhöhen und die Geschwindigkeit von Kirby erhöhen if(bodyY+bodyR>=circleY-circleR && bodyX+bodyR>=circleX-circleR && bodyX-bodyR<=circleX+circleR) { score = score+1; } //Wenn der Kreis oben verschwindet soll er eine neue Position bekommen if(circleY<=0) { circleY = circleY+height; } //Wenn Score sich erhöht, soll sich auch die Geschwindigkeit des Spiels erhöhen if(score>=20 && score<=39) { bodyVY=150; legVY=150; toeVY=150; eyeVY=150; } else if(score>=40 && score<=59){ bodyVY=200; legVY=200; toeVY=200; eyeVY=200; } else if(score>=60 && score<=79){ bodyVY=250; legVY=250; toeVY=250; eyeVY=250; } else if(score>=80 && score<=99){ bodyVY=300; legVY=300; toeVY=300; eyeVY=300; } else if(score>=100){ bodyVY=350; legVY=350; toeVY=350; eyeVY=350; } //Wenn Kirby das Ziel erreicht, ist das Spiel Gewonnen if (bodyY>tubeLength) gameState = GAMEWON; } //Wenn das Leben des Kirby auf 0 fällt ist das Spiel Gameover if (health<=0) gameState = GAMEOVER; //Hintergrund, Leben und Verlauf des Tunnels background (146,136,136); stroke(0); strokeWeight(1); for (float y=screenLeftY; y<screenLeftY+height; y+=1) { float x=0.9*width*noise (y/width); line (x, y-screenLeftY, x+tubeWidth, y-screenLeftY); fill (map(health, 0, initialHealth, 255, 0), map(health, 0, initialHealth, 0, 255), 0); rect (0,0,map(health, 0, initialHealth, 0, 500), 18); }
stroke (250,255,0); strokeWeight (5); line (0, tubeLength-screenLeftY, width, tubeLength-screenLeftY); //Kirby stroke(0); fill(98, 251, 255); strokeWeight(5); ellipseMode(CENTER); ellipse(bodyX, bodyY-screenLeftY, bodyR, bodyR); if (keyPressed && keyCode == RIGHT) { //Kirby schaut nach rechts point (eyeX, eyeY-screenLeftY); point (eyeX+15, eyeY-screenLeftY); arc(legX, legY-screenLeftY, legR, legR, TWO_PI-PI, TWO_PI); arc(legX-15, legY-screenLeftY, legR, legR, TWO_PI-PI, TWO_PI); line (toeX, toeY-screenLeftY, toeX2, toeY2-screenLeftY); line (toeX+15, toeY-screenLeftY, toeX2+15, toeY2-screenLeftY); } else if (keyPressed && keyCode == LEFT) { //Kirby schaut nach links point (eyeX-6, eyeY-screenLeftY); point (eyeX-23, eyeY-screenLeftY); arc(legX-30, legY-screenLeftY, legR, legR, TWO_PI-PI, TWO_PI); arc(legX-15, legY-screenLeftY, legR, legR, TWO_PI-PI, TWO_PI); line (toeX, toeY-screenLeftY, toeX2, toeY2-screenLeftY); line (toeX-15, toeY-screenLeftY, toeX2-15, toeY2-screenLeftY); } else { //Kirby steht still point (eyeX+2, eyeY-screenLeftY); point (eyeX-11, eyeY-screenLeftY); arc(legX-25, legY-screenLeftY, legR-7, legR, TWO_PI-PI, TWO_PI); arc(legX-5, legY-screenLeftY, legR-7, legR, TWO_PI-PI, TWO_PI); line (toeX+6, toeY-screenLeftY, toeX2+6, toeY2-screenLeftY); line (toeX-6, toeY-screenLeftY, toeX2-6, toeY2-screenLeftY); }
} //Wenn das Spiel nicht läuft d.h. sich entweder im Startmodus, Game Over oder Game Won befindet, dann soll ein blinkender Text erscheinen, der den jeweiligen Spielestatus anzeigt. if (gameState!=GAMERUNNING) { textSize (50); textAlign (CENTER, CENTER); fill (random(0,255), random(0,255), random(0,255)); if (gameState==GAMEOVER) text ("GAME OVER", width/2, height/2); else if (gameState==GAMEWON) text ("VICTORY", width/2, height/2); else if (gameState==GAMEWAIT) text ("PRESS SPACE TO START", width/2, height/2); }
//clock int m = millis(); int seconds = m / 1000; int minutes = seconds / 60; seconds -= minutes * 60;
fill (255); textSize(20); textAlign (CENTER, TOP); text (seconds, 585, 20); text (":",570, 20); text (minutes, 555, 20);
// score textSize (13); textAlign (CENTER, TOP); fill(255); text("SCORE: ",570,50); textSize (20); fill (19,250,34); text (score, 610, 45); }
hey guys! i wanted to make X and O "rain from the top to buttom. i want them to rain frrom random x positions and in random times...
do i have to define every single O and X and give them a certain position and than tell the program to let them rain in random times?
i dont get it for 100%
here you can run the program, maybe you understand my question better if you see it.
//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;
fill (0); textSize(20); textAlign (CENTER, TOP); text (seconds, 585, 20); text (":",570, 20); text (minutes, 555, 20);
//Kirby stroke(0); fill(98, 251, 255); strokeWeight(5); ellipseMode(CENTER); ellipse(bodyX, bodyY, bodyR, bodyR); if (keyPressed && keyCode == RIGHT) { //Right point (eyeX, eyeY); point (eyeX+15, eyeY); 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); } else if (keyPressed && keyCode == LEFT) { //Left point (eyeX-6, eyeY); point (eyeX-23, eyeY); arc(legX-30, 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); } else { //Still point (eyeX+2, eyeY); point (eyeX-11, eyeY); arc(legX-25, legY, legR-7, legR, TWO_PI-PI, TWO_PI); arc(legX-5, legY, legR-7, legR, TWO_PI-PI, TWO_PI); line (toeX+6, toeY, toeX2+6, toeY2); line (toeX-6, toeY, toeX2-6, toeY2); }
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:
//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);