Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- 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 Camera2DLib;
- namespace TestCam
- {
- public class Game1 : Microsoft.Xna.Framework.Game
- {
- GraphicsDeviceManager graphics;
- SpriteBatch spriteBatch;
- Texture2D[] tex = new Texture2D[2];
- CreateObjectCenter center;
- Camera cam;
- Control controlkey;
- Object2D[] array_objects = new Object2D[3];
- public Game1()
- {
- graphics = new GraphicsDeviceManager(this);
- Content.RootDirectory = "Content";
- }
- protected override void Initialize()
- {
- tex[0] = Content.Load<Texture2D>("IMG_0001O");
- tex[1] = Content.Load<Texture2D>("IMG_0006");
- center = new CreateObjectCenter(150, 150, 30, 30, tex[0]);
- controlkey = new Control(Keys.Up, Keys.Down, Keys.Left, Keys.Right);
- cam = new Camera(center, controlkey);
- Object2D ob1 = new Object2D(tex[1], new Rectangle(2,5,30,30));
- Object2D ob2 = new Object2D(tex[1], new Rectangle(160,0,30,30));
- Object2D ob3 = new Object2D(tex[1], new Rectangle(500,0,30,30));
- array_objects[0] = ob1;
- array_objects[1] = ob2;
- array_objects[2] = ob3;
- base.Initialize();
- }
- protected override void LoadContent()
- {
- spriteBatch = new SpriteBatch(GraphicsDevice);
- }
- protected override void UnloadContent()
- {
- }
- protected override void Update(GameTime gameTime)
- {
- if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
- this.Exit();
- cam.Update(20, array_objects);
- if (Keyboard.GetState().IsKeyDown(Keys.F1))
- {
- cam.Zoom(array_objects, 0, 50);
- }
- if (Keyboard.GetState().IsKeyDown(Keys.F2))
- {
- cam.Zoom(array_objects, 1, 50);
- }
- cam.MoveCamera(array_objects,100,-100);
- base.Update(gameTime);
- }
- protected override void Draw(GameTime gameTime)
- {
- GraphicsDevice.Clear(Color.CornflowerBlue);
- DrawAllObjects draw = new DrawAllObjects(array_objects, spriteBatch);
- center.DrawObject(spriteBatch);
- base.Draw(gameTime);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement