/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } if (Keyboard.GetState().IsKeyDown(Keys.R)) { ballsim = new BallSimulation(); //explosionview = new Applicationview(Content, camera, spriteBatch); startview = new Startview(Content, camera, spriteBatch, ballsim, graphics); } var currentmouse = Mouse.GetState(); if (lastmouseclick.LeftButton == ButtonState.Released && currentmouse.LeftButton == ButtonState.Pressed) { startview.CreateExplosion(currentmouse.X, currentmouse.Y, spriteBatch); } lastmouseclick = currentmouse; ballsim.UpdateBall((float)gameTime.ElapsedGameTime.TotalSeconds); base.Update(gameTime); }
public Startview(ContentManager _content, Camera _camera, SpriteBatch _spritebatch, BallSimulation _ballsim, Playersimulation _playersim, Drawmap _drawmap, GraphicsDeviceManager _graphics) { content = _content; //Camera etc.. camera = _camera; spritebatch = _spritebatch; ballsim = _ballsim; playersim = _playersim; drawmap = _drawmap; graphics = _graphics; balltexture = content.Load <Texture2D>("BALL"); //Balltexture ballcenter = new Vector2(balltexture.Width / 2, balltexture.Height / 2); //Ballcenter playersprite = content.Load <Texture2D>("Player"); playercenter = new Vector2(playersprite.Width / 2, playersprite.Height / 2); ballbackgroundtexture = content.Load <Texture2D>("Ballground"); //Sprites playerbackgroundtexture = content.Load <Texture2D>("Playergroundtile"); playercreatestexture = content.Load <Texture2D>("Playercreatingground"); maptextures.Add(ballbackgroundtexture); //Sprites added to list maptextures.Add(playerbackgroundtexture); maptextures.Add(playercreatestexture); map = lvlone.getmap(); //Gets the map totalballs = ballsim.getballs(); //Gets the amount of balls player = playersim.getplayer(); }
public Startview(ContentManager _content, Camera _camera, SpriteBatch _spritebatch, BallSimulation _ballsim, GraphicsDeviceManager _graphics) { content = _content; camera = _camera; spritebatch = _spritebatch; ballsim = _ballsim; graphics = _graphics; fieldsize = camera.ReturnFieldsize(); bordersize = camera.ReturnBorder(); rect = new Rectangle(bordersize, bordersize, fieldsize, fieldsize); splittertexture = content.Load <Texture2D>("spark"); smoketexture = content.Load <Texture2D>("smoke"); explosiontexture = content.Load <Texture2D>("explosion"); shockwavetexture = content.Load <Texture2D>("Shockwave"); balltexture = content.Load <Texture2D>("BALL"); deadball = content.Load <Texture2D>("Deadball"); crosshair = content.Load <Texture2D>("Crosshair"); firesound = content.Load <SoundEffect>("fire"); ballcenter = new Vector2(balltexture.Width / 2, balltexture.Height / 2); background = new Texture2D(graphics.GraphicsDevice, 1, 1); background.SetData(new Color[] { Color.Black }); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here ballSimulation = new BallSimulation(); base.Initialize(); }
public BallView(BallSimulation Ballsimulation, Camera Camera, GraphicsDevice Graphics, Texture2D BallTexture) { ballSimulation = Ballsimulation; camera = Camera; ballTexture = BallTexture; backGroundTexture = new Texture2D(Graphics, 1, 1); backGroundTexture.SetData(new[] { Color.White }); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); ballTexture = Content.Load <Texture2D>("aqua-ball.png"); ballSimulation = new BallSimulation(); ballView = new BallView(graphics, ballSimulation, ballTexture); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here Texture2D ball = Content.Load <Texture2D>("ball4"); model = new BallSimulation(); view = new BallView(GraphicsDevice, ball); }
public BallController(GraphicsDeviceManager graphics, ContentManager content, BallSimulation ballSimulation) { box = new Texture2D(graphics.GraphicsDevice, 1, 1); box.SetData <Color>(new Color[] { Color.White }); camera = new Camera(graphics.GraphicsDevice.Viewport); globe = content.Load <Texture2D>("globe.png"); m_ballSimulation = ballSimulation; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here ballSimulation = new BallSimulation(); ballController = new BallController(graphics, Content, ballSimulation); }
public MasterController() : base() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; graphics.PreferredBackBufferWidth = 700; graphics.PreferredBackBufferHeight = 700; m_bs = new BallSimulation(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here m_camera = new Camera(GraphicsDevice.Viewport); m_bv = new BallView(); m_bs = new BallSimulation(); m_gameCon = new GameController(Content); this.IsMouseVisible = true; base.Initialize(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { camera.SetFieldSize(graphics.GraphicsDevice.Viewport); // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); ballsim = new BallSimulation(); //explosionview = new Applicationview(Content, camera, spriteBatch); startview = new Startview(Content, camera, spriteBatch, ballsim, graphics); // TODO: use this.Content to load your game content here }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here ballSimulation = new BallSimulation(); ballTexture = Content.Load <Texture2D>("Ball.png"); Camera camera = new Camera(GraphicsDevice.Viewport); ballView = new BallView(ballSimulation, camera, GraphicsDevice, ballTexture); }
private void Init() { serviceInitializer = new ServiceInitializerIK(sliders); serviceInitializer.InitializeSliders(); serviceRotation = ScriptableObject.CreateInstance <ServiceRotationIK>(); serviceRotation.Init(topLegs, bottomLegs); inverseKinematics = ScriptableObject.CreateInstance <InverseKinematics>(); ballSimulation = new BallSimulation(sliders); panelDrawing = new PanelDrawing(panels); }
public BallView(GraphicsDeviceManager graphics, BallSimulation BallSimulation, Texture2D ball) { _camera = new Camera(graphics); _ballSimulation = BallSimulation; _ball = ball; _ballCenter = new Vector2(_ball.Width / 2, _ball.Height / 2); _camera.setSizeOfField(); _rect = _camera.getRect(); _background = new Texture2D(graphics.GraphicsDevice, 1, 1); _background.SetData(new Color[] { Color.Tomato }); }
public BallView(GraphicsDeviceManager graphics, BallSimulation BallSimulation, ContentManager Content, Texture2D Ball, Texture2D deadBall) /// en konstruktor som laddar in först i klassen! { ballTexture = Ball; ///laddar in bollen //detta görs bara en gång! this.deadBall = deadBall; box = new Texture2D(graphics.GraphicsDevice, 1, 1); ///denna skapar en box box.SetData(new Color[] { Color.Black }); /// denna sätter vilken färg! camera = new Camera(graphics.GraphicsDevice.Viewport); /// skapar en ny camera instans ballSimulation = BallSimulation; }
public void LoadContent(SpriteBatch _spritebatch, ContentManager _content, Camera _camera) { spriteBatch = _spritebatch; Content = _content; camera = _camera; ballsim = new BallSimulation(); playersim = new Playersimulation(); drawmap = new Drawmap(); lvlone = new LevelOne(); startview = new Startview(Content, camera, spriteBatch, ballsim, playersim, drawmap, graphics); //Loads the map once when the application starts. Will use update function to call a function in drawmap that allows me to place new tiles.. map = lvlone.getmap(); textures = startview.ReturnedTextures(); drawmap.Drawlevel(map, textures, spriteBatch, camera); }
//Metod som ritar ut bollen internal void DrawBall(BallSimulation ballSimulation) { //int size = windowWidth / 10; Ball ball = new Ball(); int vx = (int)(ballSimulation.getXPosition() * camera.getScale() + camera.GetFrame()); int vy = (int)(ballSimulation.getYPosition() * camera.getScale() + camera.GetFrame()); int size = (int)(ball.diameter * camera.getScale()); rotation += 0.01f; Rectangle destrect = new Rectangle(vx - size / 2, vy - size / 2, size, size); Rectangle srcRect = new Rectangle(0, 0, ballTexture.Width, ballTexture.Height); Vector2 origin = new Vector2(187 / 2, 226 / 2); spriteBatch.Begin(); spriteBatch.Draw(ballTexture, destrect, Color.White); //spriteBatch.Draw(ballTexture, destrect, srcRect, Color.White, rotation, origin, SpriteEffects.None, 0); //spriteBatch.Draw(ballTexture, new Vector2(vx, vy), srcRect, Color.White, rotation, origin, new Vector2(size / (float)ballTexture.Width, size / (float)ballTexture.Height), SpriteEffects.None, 0); spriteBatch.End(); }
//BallView ballview; public Explosion(SpriteBatch spritebatch, Texture2D Particle, Camera Camera, Texture2D Smoke, Texture2D BangExplosion, SoundEffect explosionSound, Texture2D CursorImage, BallSimulation bs) { timeElapsed = 0; //denna ska vara 0 när programmet startas //ballview = Ballview; //this.masterBallDead = masterBallDead; cursorImage = CursorImage; //cursorPos = CursorPosition; camera = Camera;//så jag kan använda kameran i klassen! spriteBatch = spritebatch; particle = Particle; bangExplosion = BangExplosion; smoke = Smoke; Width = particle.Width; // posFramesX; //delar explosionens bredd med positions framesen! Height = particle.Height; // posFramesY; soundEffect = explosionSound; particleSystem = new ParticleSystem(startposition); smokeSystem = new SmokeSystem(smoke, startposition, camera);//får inte denna att fungera explosionManager = new ExplosionManager(spriteBatch, BangExplosion, camera, startposition); ballSimulation = bs; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); camera = new Camera(graphics.GraphicsDevice.Viewport); Texture2D smokee = Content.Load <Texture2D>("particlesmokee"); Texture2D spark = Content.Load <Texture2D>("spark"); Texture2D bangExplosion = Content.Load <Texture2D>("explosion"); Texture2D masterBall = Content.Load <Texture2D>("master_ball"); Texture2D masterBallDead = Content.Load <Texture2D>("master_ball_dead2"); cursorImage = Content.Load <Texture2D>("Pointer"); SoundEffect explosionSound = Content.Load <SoundEffect>("firesound"); Vector2 startPosition = new Vector2(0.5f, 0.5f); ballSimulation = new BallSimulation(); explosion = new Explosion(spriteBatch, spark, camera, smokee, bangExplosion, explosionSound, cursorImage, ballSimulation); smokeSystem = new SmokeSystem(smokee, startPosition, camera); ballview = new BallView(graphics, ballSimulation, Content, masterBall, masterBallDead); // TODO: use this.Content to load your game content here }
void Awake() { _ballLogic = new BallLogic(); _ballSimulation = new BallSimulation(this); _ballLogic.OnDestroy += DestroyBall; }
void Awake() { ballSimulation = new BallSimulation(InitialVelocity); BallLogic = new BallLogic(this, ballSimulation); BallLogic.OnDestroyed += () => Destroy(gameObject); }
public BallLogic(ILocalPositionAdapter localPositionAdapter, BallSimulation ballSimulation) { this.localPositionAdapter = localPositionAdapter; this.ballSimulation = ballSimulation; }