We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I can not figure why this isn't working for me. It won't load the player on the screen or the falling objects I have chosen. Can someone please help me fix this?
NightSky nightsky;
Player player;
Flower flower;
//Call variables for Flowers and Player.
int nX = 0;
int nY = 0;
float aY = 0;
int aX = 15;
float aV = 3;
//Variable to set up menu.
int stage;
//Images for 2 menu pages and main game page.
PImage Back_G,Fore_G,Direct,Title;
void setup(){
stage=1;
size(800,500);
nY = height - 25;
//Load images for menus.
Back_G = loadImage("Background.png");
Fore_G = loadImage("Ground.png");
Direct = loadImage("Directions.png");
Title = loadImage("Title_Screen.png");
flower = new Flower();; player = new Player();
nightsky = new NightSky(50);
image(Title,0,0,width,height);
//How fast snow falls.
frameRate(7);
smooth();
} void draw() {
if (stage==1) {
} else if (stage==2) {
image(Direct, 0, 0, width, height);
} else if (stage==3) {
background(0);
nightsky.draw();
image(Back_G, 0, 0);
image(Fore_G,0,0);
player.display();
flower.draw();
} //Collision for flowers and player.
if (aY + 10 > nY && aY - 10 < nY + 20) {
if (aX + 10 > nX && aX - 10 < nX + 20) {
fill(255, 0, 0);
}
//What happens when menu pages are clicked.
void mouseClicked() {
if (stage==1) {
stage=2;
} else if (stage==2) {
stage=3;
} else if (stage==3) {
} }
class Flower{
//Variable to set up falling flowers and snow.
int aY = 0;
int aX = 15;
float aY = 0;
float aV = 3;
//Images of 2 flowers and 1 snowball.
PImage FF;
PImage PF;
PImage SF;
Flower(){
//Load images for flowers and snowflake.
FF = loadImage("Fire_Flower.png");
PF = loadImage("Poison_Flower.png");
SF = loadImage("Snow_Flake.png");
} void draw(){
//Position of flower,flakes.
aY = aY + aV;
if (aY > height) {
aY = 15;
aX = int(random(width - 20));
}
image(FF,aY,50,50,0);
image(PF,aY,50,50,0);
image(SF,aY,50,50,0);
} }
class Flower{
//Variable to set up falling flowers and snow.
int aY = 0;
int aX = 15;
float aY = 0;
float aV = 3;
//Images of 2 flowers and 1 snowball.
PImage FF;
PImage PF;
PImage SF;
Flower(){
//Load images for flowers and snowflake.
FF = loadImage("Fire_Flower.png");
PF = loadImage("Poison_Flower.png");
SF = loadImage("Snow_Flake.png");
} void draw(){
//Position of flower,flakes.
aY = aY + aV;
if (aY > height) {
aY = 15;
aX = int(random(width - 20));
}
image(FF,aY,50,50,0);
image(PF,aY,50,50,0);
image(SF,aY,50,50,0);
} }
class Player{
//Variable coordinate for player.
int nX = 0;
//Player image.
PImage Arie;
Player(){
Arie = loadImage("Arie.png");
}
void display(){
//Setup coordinates for player.
image(Arie,nX, height - 25, 100, 100);
}
//Controls for player.
void keyPressed() {
// Right arrow.
if (keyCode == RIGHT) {
nX = nX + 3;
}
// Left arrow.
if (keyCode == LEFT) {
nX = nX - 3;
}
//So the player doesn't travel outside border boundaries.
if (nX < 0) {
nX = 0;
}
if (nX > width - 20) {
nX = width - 20;
} } } }
Answers
http://forum.processing.org/two/discussion/8045/how-to-format-code-and-text