Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Audio;
- using Microsoft.Xna.Framework.Content;
- using Microsoft.Xna.Framework.GamerServices;
- using Microsoft.Xna.Framework.Graphics;
- using Microsoft.Xna.Framework.Input;
- using Microsoft.Xna.Framework.Media;
- using Microsoft.Xna.Framework.Net;
- using Microsoft.Xna.Framework.Storage;
- namespace Platformer
- {
- public class Tank
- {
- public bool firstplayer;
- private Vector2 player_pos;
- Texture2D tankfel;
- Texture2D tankle;
- Texture2D tankbalra;
- Texture2D tankjobbra;
- private int facing; //0: left , 1: right, 2: up, 3: down
- public Tank(bool first, Texture2D bal, Texture2D jobb, Texture2D fel, Texture2D le)
- {
- firstplayer = first;
- if (firstplayer)
- facing = 1;
- else
- facing = 0;
- tankfel = fel;
- tankbalra = bal;
- tankjobbra = jobb;
- tankle = le;
- }
- public void Update()
- {
- }
- public void Draw(SpriteBatch rajz)
- {
- if(facing == 0)
- rajz.Draw(tankbalra, new Rectangle((int)player_pos.X * 64, (int)player_pos.Y * 64, 64, 64), Color.White);
- else if(facing == 1)
- rajz.Draw(tankjobbra, new Rectangle((int)player_pos.X * 64, (int)player_pos.Y * 64, 64, 64), Color.White);
- else if(facing == 2)
- rajz.Draw(tankfel, new Rectangle((int)player_pos.X * 64, (int)player_pos.Y * 64, 64, 64), Color.White);
- else
- rajz.Draw(tankle, new Rectangle((int)player_pos.X * 64, (int)player_pos.Y * 64, 64, 64), Color.White);
- }
- public void DoKeyBoardActions(KeyboardState bill)
- {
- if (firstplayer)
- {
- if (bill.IsKeyDown(Keys.A))
- Move(0);
- if (bill.IsKeyDown(Keys.W))
- Move(1);
- if (bill.IsKeyDown(Keys.S))
- Move(2);
- if (bill.IsKeyDown(Keys.D))
- Move(3);
- }
- else
- {
- if (bill.IsKeyDown(Keys.Left))
- Move(0);
- if (bill.IsKeyDown(Keys.Up))
- Move(1);
- if (bill.IsKeyDown(Keys.Down))
- Move(2);
- if (bill.IsKeyDown(Keys.Right))
- Move(3);
- }
- }
- public void Move(int irany)
- {
- if (firstplayer)
- {
- if (irany == 0)
- {
- player_pos.X += 1;
- facing = 0;
- }
- if (irany == 1)
- {
- player_pos.Y -= 1;
- facing = 0;
- }
- }
- else
- {
- }
- }
- public void SetPos(Vector2 pos)
- {
- player_pos = pos;
- }
- public Vector2 GetPos()
- {
- return player_pos;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement