Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Content;
- using Microsoft.Xna.Framework.Graphics;
- using Microsoft.Xna.Framework.Input;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Pong
- {
- class Rockets
- {
- public Rectangle rocketUp1;
- public Rectangle rocketMiddle1;
- public Rectangle rocketDown1;
- public Rectangle rocketUp2;
- public Rectangle rocketMiddle2;
- public Rectangle rocketDown2;
- public Texture2D rocketTexture1;
- public Texture2D rocketTexture2;
- public Rockets()
- {
- rocketUp1 = new Rectangle(0, 250, 25, 25);
- rocketMiddle1 = new Rectangle(0, 275, 25, 25);
- rocketDown1 = new Rectangle(0, 300, 25, 25);
- rocketUp2 = new Rectangle(775, 250, 25, 25);
- rocketMiddle2 = new Rectangle(775, 275, 25, 25);
- rocketDown2 = new Rectangle(775, 300, 25, 25);
- }
- public void LoadContent(ContentManager Content)
- {
- rocketTexture1 = Content.Load<Texture2D>("rocket_1");
- rocketTexture2 = Content.Load<Texture2D>("rocket_2");
- }
- public void Update(GameTime gameTime)
- {
- if(Keyboard.GetState().IsKeyDown(Keys.Q))
- {
- rocketUp1.Y -= 2;
- rocketMiddle1.Y -= 2;
- rocketDown1.Y -= 2;
- }
- if (Keyboard.GetState().IsKeyDown(Keys.A))
- {
- rocketUp1.Y += 2;
- rocketMiddle1.Y += 2;
- rocketDown1.Y += 2;
- }
- if (Keyboard.GetState().IsKeyDown(Keys.P))
- {
- rocketUp2.Y -= 2;
- rocketMiddle2.Y -= 2;
- rocketDown2.Y -= 2;
- }
- if (Keyboard.GetState().IsKeyDown(Keys.L))
- {
- rocketUp2.Y += 2;
- rocketMiddle2.Y += 2;
- rocketDown2.Y += 2;
- }
- if(rocketUp1.Y <= 0)
- {
- rocketUp1.Y = 0;
- rocketMiddle1.Y = 25;
- rocketDown1.Y = 50;
- }
- if (rocketUp2.Y <= 0)
- {
- rocketUp2.Y = 0;
- rocketMiddle2.Y = 25;
- rocketDown2.Y = 50;
- }
- if (rocketUp1.Y >=525)
- {
- rocketUp1.Y = 525;
- rocketMiddle1.Y = 550;
- rocketDown1.Y = 575;
- }
- if (rocketUp2.Y >= 525)
- {
- rocketUp2.Y = 525;
- rocketMiddle2.Y = 550;
- rocketDown2.Y = 575;
- }
- }
- public void Draw(SpriteBatch spriteBatch)
- {
- spriteBatch.Draw(rocketTexture1, rocketUp1, Color.White);
- spriteBatch.Draw(rocketTexture1, rocketMiddle1, Color.White);
- spriteBatch.Draw(rocketTexture1, rocketDown1, Color.White);
- spriteBatch.Draw(rocketTexture2, rocketUp2, Color.White);
- spriteBatch.Draw(rocketTexture2, rocketMiddle2, Color.White);
- spriteBatch.Draw(rocketTexture2, rocketDown2, Color.White);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement