Please HELP with my game!!! URGENT!
in
Programming Questions
•
3 months ago
I'm trying to male an aliene game where there is meteors/balls flying all around and if one catches you you die OR alternatively an alien that had to catch the balls in however long time, however finding it soooooo hard!
Heres my code so far, doesn't work :(
1st tab=
//Declaring
//library for music
import ddf.minim.* ;
//Variables
PImage img;//background
AudioPlayer player;
Minim minim;
Alien myAlien;
Ball myMoon;
//
void setup() {
size(800, 800); //size of screen
smooth();
ellipseMode(RADIUS);
shapeMode(CENTER);
//background image
img = loadImage("space.jpg");
image(img,0,0);
//music
minim = new Minim(this) ;
player = minim.loadFile("Free Video Game Music.mp3");
player.play();
//alien
score = 0;
myAlien = new Alien(450, 320, 200, 220);
myAlien = new Ball(200,200);
}
void draw(){
background(img);
fill(color(229,228,178));
myAlien.drawAlien();
myAlien.move();
fill(color(178,65,172));
//moon balls
myMoon.display();
myMoon.move();
myMoon.bounce();
myMoon.gravity();
if(myAlien.checkForOverlap(myMoon)) {
for(int i = 0; i < 50; i++) { //function of moon balls
Ball myMoon = (Ball) ballGroup.get(i);
myMoon.run();
if(vanish==true)
{
destroy(mousePressed);
vanish = false;
}
moons();
text ( "Game over": ", 400,40);
GameOver();
}
}
//music stop
{
minim.stop();
super.stop();
}
//
2nd=
class Alien {
//Variables for Class Alien
int bodyXLoc;
int bodyYLoc;
int bodyWidth;
int bodyHeight;
int antennaeWidth;
int antennaeHeight;
int antennaeHeight;
int antennaeXLoc;
int antennaeYLoc;
int eyeboxWidth;
int eyeboxHeight;
int eyeboxXLoc;
int eyeboxYLoc;
int Alien = 0;
int ySpeed;
int xSpeed;
//class description
Alien(int x, int y, int meteorWidth, int meteorHeight) {
bodyXLoc = x;
bodyYLoc = y;
bodyWidth = meteorWidth;
bodyHeight = meteorHeight;
}
//making the alien using the main body
void drawAlien() {
// main body
rect(bodyXLoc, bodyYLoc, bodyWidth, bodyHeight);
//antennae
antennaeWidth = bodyHeight/4;
antennaeHeight = antennaeWidth;
antennaeXLoc = bodyXLoc;
antennaeYLoc = bodyYLoc -(bodyHeight / 2) - (headHeight /2);
rect(antennaeXLoc, antennaeYLoc, antennaeWidth, antennaeHeight);
fill(96,44,209);
//eyes
int eyeboxWidth = bodyWidth / 2;//width eyes
int eyeboxHeight = antennaeHeight / 2; //height eyes
int eyeboxXLoc = bodyXLoc;
int eyeboxYLoc = bodyYLoc;
rect(eyeboxXLoc, eyeboxYloc, eyeboxWidth, eyeboxHeight); //green background of eyes
fill(58,170,36);
}
void move() {
bodyXLoc = bodyXLoc + xSpeed;
bodyYLoc = bodyYLoc + ySpeed;
//checking for balls
if(bodyyLoc > width - (Alien / 2) || bodyyLoc < 0 + (Alien/2)) {
xSpeed = xSpeed * - 1;
}
}
if(bodyYLoc > height - (Alien / 2) || yPos < 0 + (Alien / 2)) {
ySpeed = ySpeed * - 1;
}
//
3rd tab =
Class Ball {
//Variables for Class Ball
float x= 0;
float y = 0;
float speedX = random(-1,1)
float speedY = random(-1,1)
//Description
Ball(float _x, float _y) {
x = _x;
y = _y;
}
void gravity(){
speedY += 0.2;
}
void bounce() {
if(x > width) {
speedX =speedX * -1;
}
if(x < 0) {
speedX =speedX * -1;
}
if(y > height) {
speedX =speedX * -1;
}
if(y < 0) {
speedY =speedY * -1;
}
1