Click here to Skip to main content
15,996,252 members
Please Sign up or sign in to vote.
1.89/5 (2 votes)
See more:
ok, so I've been trying to figure out how to solve this error for hours and I know it has something to do with the curly braces but I can't seem to pinpoint where. Any help is appreciated. The error is on my method line and all the methods after it. Thanks in advance.




using System;
using System.Collections.Generic;

using Sce.PlayStation.Core;
using Sce.PlayStation.Core.Environment;
using Sce.PlayStation.Core.Graphics;
using Sce.PlayStation.Core.Input;
using Sce.PlayStation.Core.Audio;
using System.Linq;
namespace Game2
{
	public class AppMain
	{
		private static GraphicsContext graphics;
		private static Texture2D BG;
		private static Player hero, hero2;
		private static Sprite back, back2;
		private static Vector3 pos1,pos2,pos3,pos4,pos5,pos6,pos7,pos8,pos9;
		private static bool running;
		private static BgmPlayer bgmp;
		private static List<Bullet> bullets;
		private static List<Enemy> eList;
		private static List<Player> pList;
		
		
		
		
		
		public static void Main (string[] args)
		{
			Initialize ();

			while (running) {
				SystemEvents.CheckEvents ();
				Update ();
				Render ();
				
			
			}
		}

		public static void Initialize ()
		{
			// Set up the graphics system
			graphics = new GraphicsContext ();
			
			//sets the position of the two players
			pos1=new Vector3(100,400,0);
			pos2=new Vector3(500,400,0);
			pos3=new Vector3(100,100,0);
			pos4=new Vector3(160,100,0);
			pos5=new Vector3(220,100,0);
			pos6=new Vector3(280,100,0);
			pos7=new Vector3(340,100,0);
			pos8=new Vector3(400,100,0);
			pos9= new Vector3(460,100,0);
			
			
		
			
			
			
			
			
			
			running=true;
			
			//creates two object of the Player class and an object of the Enemy class
			pList= new List<Player>();
			hero = new Player (1,graphics,pos2);
			hero2 = new Player (2,graphics,pos1);
			pList.Add (hero);
			pList.Add (hero2);
			
			eList= new List<Enemy>();
			Enemy e1=new Enemy(graphics,pos3,0.1);
			eList.Add(e1);
			Enemy e2=new Enemy(graphics,pos4,0.2);
			eList.Add(e2);
			Enemy e3=new Enemy(graphics,pos5,0.3);
			eList.Add(e3);
			Enemy e4=new Enemy(graphics,pos6,0.4);
			eList.Add(e4);
			Enemy e5=new Enemy(graphics,pos7,0.5);
			eList.Add(e5);
			Enemy e6=new Enemy(graphics,pos8,0.6);
			eList.Add(e6);
			Enemy e7=new Enemy(graphics,pos9,0.7);
			eList.Add(e7);
			
			
			bullets = new List<Bullet>();
			
			
			
			
			
			
			//processes the background and sets the position
			
		
			BG = new Texture2D ("/Application/Assets/Bckgd.png", false);
			
			back = new Sprite (graphics, BG);
			
			back.Position.X = 0;
			
			back.Position.Y = 0;
			
			back2 = new Sprite (graphics, BG);
			
			back2.Position.X = 0;
			
			back2.Position.Y = back.Height;
			
			Bgm bgm =  new Bgm("/Application/Assets/song.mp3");
			bgmp = bgm.CreatePlayer();
			bgmp.Loop=true;
			bgmp.Play();
			
			
			
			
			
		
			
			
			
			
			
			
		
			
			
			
	
		}

		public static void Update ()
		{
			// Query gamepad for current state
			var gamePadData = GamePad.GetData (0);
			//Updates the the two objects of the Player Class and the Enemy Class
			
			
			
			if ((gamePadData.Buttons & GamePadButtons.Select) !=0)
			{
				running=false;
			}
		}
			
			private static void PlayerReg()
		{
		foreach(Player k in pList)
			{
				k.Update(gamePadData);
			}
		}
		
		private static void EnemReg()
		{
		foreach(Enemy z in eList){
				z.Update();
			}
		}
		private static void BulletReg()
		{
		foreach(Bullet b in bullets)
			{
			b.Update();
			}
		
		
			
			//Bullets
			BulletReg();
			EnemReg();
			PlayerReg();
			
			
			
			
			//vertically scrolls the background
			back.Position.Y--;
			
			back2.Position.Y--;
			
			if (back.Position.Y < -back.Height)
				back.Position.Y = back.Height;
			if (back2.Position.Y <= -back2.Height)
				back2.Position.Y = back2.Height;
 				
			//Bullets
			
			
			if ((gamePadData.Buttons & GamePadButtons.L) !=0)
			{
				Bullet b= new Bullet(graphics,hero.Pos);
				
				bullets.Add (b);
			}
			
			if ((gamePadData.Buttons & GamePadButtons.R) !=0)
			{
				Bullet b= new Bullet(graphics,hero2.Pos);
				bullets.Add(b);
			}
		}
		
		
	}
}

		

		
		
		
		
		
		public static void Render ()
		{
			// Clear the screen
			graphics.SetClearColor (0.0f, 0.0f, 0.0f, 0.0f);
			graphics.Clear ();
			
			//draws the sprites to the screen
			back.Render ();
			
			back2.Render ();
			
			foreach(Player k in pList){
				k.Render();
			}
			
			foreach(Enemy z in eList){
				z.Render();
			}
			
			foreach(Bullet b in bullets){
				b.Render();
			}
			
			
			
			//bULLETS
			foreach(Bullet b in bullets)
			{
			b.Render();
					
			}
			// Present the screen
			graphics.SwapBuffers ();
		
		public static void collisions()
		{
			for(int k=pList.Count-1;k>=0;k--)
			{
			 for(int b=bullets.Count-1;b>=0;b--)
				{
			if (Vector3.Distance (pList[k].Center, bullets [b].Center) < pList[k].Radius+bullets [b].Radius)
					{
						bullets.RemoveAt(b);
						break;
						
					}
				}
	        }
	
			
		}
		public void Collisions2()
		{
			for(int k=pList.Count-1;k>=0;k--)
			{
				for(int z=eList.Count-1;z>=0;z--)
				{
			if (Vector3.Distance(pList[k].Center, eList[z].Center)< pList[k].Radius+eList[z].Radius)
					   {
						eList.RemoveAt(z);
						pList.RemoveAt(k);
						break;
					}
					}
}}}}
Posted
Comments
Member 10770869 23-Apr-14 22:15pm    
Sorry I meant to say my Render method line and every method after it
[no name] 24-Apr-14 1:26am    
We are unable to understand your problem

1 solution

Even the unarmed eye could see the lack of closing '}' at the end of Render; you told it yourself. I don't understand how it can be a problem. You did not show exact line and exact error message, but the IDE shows you everything, especially clearly if this is C#.

This is not the only problem. This method is static, so you do have access to the static members like back and back2, but you are using the syntax of instance member access. Static fields are generally bad. Here, you need to read about the very basics of OOP: fields and methods, static vs instance ones. And so on…

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900