
import java.util.ArrayList;

import processing.core.*;

public class Test extends PApplet {
	
	Astro astro;
	speedPowerup speed;
	Startmenu start;
	Endmenu end;
	ArrayList<Stars> star =new ArrayList<Stars>();
	ArrayList<Walls> topwalls = new ArrayList<Walls>();
	ArrayList<Bottomwall> botwalls = new ArrayList<Bottomwall>();
	ArrayList<speedPowerup> speeds = new ArrayList<speedPowerup>();
	//int for game state 1=startmenu 2=game 3=restart menu
	int state;
	public void setup() 
	{
		size(800,800);
		background(0);
		state=1;
		for(int i=0; i<200;i++)
		{
			Stars stars = null;
		    stars = new Stars(this);
		    star.add(stars);
		}
		astro = new Astro(width/2, height/2, 100, this);
		start = new Startmenu(this);
		end = new Endmenu(this);
	}
	boolean[] keys = new boolean[512];

	public void keyPressed()
	{
	  keys[keyCode] = true;
	}

	public void keyReleased()
	{
	  keys[keyCode] = false;
	}
	public void draw() 
	{
		background(0);
	    for(int i= star.size()-1; i>=0;i--)
	    {
	    	Stars go = star.get(i);  
	        go.update();
	        go.render();
	    }
	    if(state==1)
	    {
	    	startmenu();
	    	if(keyPressed)
	    	{
	    		state=2;
	    	}
	    }
	    if(state==2)
	    {
	    	game();
	    	if(astro.fuel==0)
	    	{
	    		state=3;
	    	}
	    }
	    if(state==3)
	    {
	    	endmenu();
	    }
	    
	    
	}
	public void topwalldetect()
	{
		for(int i= topwalls.size()-1; i>=0;i--)
	    {
	    	Walls go = topwalls.get(i);  
	        if(astro.pos.y<go.h)
	        {
	        	if((astro.pos.x+astro.w/2-10)>go.wallpos.x  && (astro.pos.x+astro.w/2-10)<(go.wallpos.x+go.w) || (astro.pos.x-astro.w/2+5)>go.wallpos.x  && (astro.pos.x-astro.w/2+5)<(go.wallpos.x+go.w))
	        	{
	        		ellipse(width/2,height/2,50,50);
	        	}
	        }
	    }
	}
	public void bottomwalldetect()
	{
		for(int i= botwalls.size()-1; i>=0;i--)
	    {
			Bottomwall go = botwalls.get(i); 
	        if(astro.pos.y+astro.w>height-go.h)
	        {
	        	if(astro.pos.x-astro.w/2>go.wallpos.x && astro.pos.x-astro.w/2<(go.wallpos.x)+go.w || astro.pos.x+astro.w/2-15>go.wallpos.x && astro.pos.x+astro.w/2-15<(go.wallpos.x)+go.w)
	        	{
	        		rect(width/2,height/2,50,50);
	        	}
	        }
	    }
	}
	public void startmenu()
	{
		start.render();
	    start.update();
	}
	public void endmenu()
	{
		end.render();
		end.update();
	}
	public void game()
	{

	    if (frameCount % 100 == 0)
	    {
	    	//initialise top wall
		    Walls topwall = null;
		    topwall = new Walls(this);
		    topwalls.add(topwall);
		    //initialise bottom wall
		    Bottomwall bottomwall = null;
		    bottomwall = new Bottomwall(this);
		    botwalls.add(bottomwall);
	    }
	    if (frameCount % 600 == 0)
	    {
	    	//initialise speedPowerup
	    	speedPowerup speed = null;
		    speed = new speedPowerup(this);
		    speeds.add(speed);
		    
	    }
		if(frameCount % 25 == 0)
		{
			astro.fuel-=2;
		}
	    
	    for(int i= speeds.size()-1; i>=0;i--)
	    {
	    	speedPowerup go = speeds.get(i);  
	        go.update();
	        go.render();
	    }
	    astro.render();
	    astro.update();
	    astro.fuel();
	    
	    for(int i= topwalls.size()-1; i>=0;i--)
	    {
	    	Walls go = topwalls.get(i);  
	        go.update();
	        go.render();
	    }
	    
	    for(int i= botwalls.size()-1; i>=0;i--)
	    {
	    	Bottomwall go = botwalls.get(i);  
	        go.update();
	        go.render();
	    }
	    topwalldetect();
	    bottomwalldetect();
	}
	
}
@@ -1723,39 +1723,20 @@
   %09%09
-ellipse(width/2,height/2,50,50)
+astro.fuel=0
 ;%0A%09 
@@ -2153,37 +2153,30 @@
   %09%09
-rect(width/2,height/2,50,50);
+astro.fuel=0;        %09
 %0A%09  
@@ -2197,32 +2197,34 @@
     %7D%0A%09    %7D%0A%09%7D%0A
+%09%0A
 %09public void sta
@@ -3456,9 +3456,11 @@
 );%0A%09%7D%0A%09%0A
+%09%0A
 %7D

kill astronaut on contact with walls