so when you intersect with the box, if ((block.boundingBox)) I think I've done quite a good job for a beginner but don't know what to do next. SpriteBatch.Draw(blockTex, blockPos, Color.White) This is my Block.cs using System using using System.Linq īoundingBox = new Rectangle((int)blockPos.X, (int)blockPos.Y, blockTex.Width, blockTex.Height) SpriteBatch.Draw(playerTex, playerPos, Color.White) Public void Draw(SpriteBatch spriteBatch) KeyboardState newState = Keyboard.GetState() Public void LoadContent(ContentManager Content)īoundingBox = new Rectangle((int)playerPos.X, (int)playerPos.Y, playerTex.Width, playerTex.Height) Public Player(int positionX, int positionY) This is my Player.cs using System using using System.Linq GraphicsDevice.Clear(Color.CornflowerBlue) Protected override void Draw(GameTime gameTime) / This is called when the game should draw itself. If (GamePad.GetState(PlayerIndex.One).Buttons.Back = ButtonState.Pressed) Protected override void Update(GameTime gameTime) / Provides a snapshot of timing values. / checking for collisions, gathering input, and playing audio. / Allows the game to run logic such as updating the world, TODO: Unload any non ContentManager content here / UnloadContent will be called once per game and is the place to unload SpriteBatch = new SpriteBatch(GraphicsDevice) Create a new SpriteBatch, which can be used to draw textures. / LoadContent will be called once per game and is the place to load TODO: Add your initialization logic here Calling base.Initialize will enumerate through any components / This is where it can query for any required services and load any non-graphic / Allows the game to perform any initialization it needs to before starting to run. Graphics.PreferredBackBufferHeight = 600 Graphics = new GraphicsDeviceManager(this) This is my Game1.cs using System using using System.Linq So if I intersect them I don't know what to do next. I have made a player class and a block class, in my Game1 class I have checked for the collision, don't know if this is a right way, but it's only a test right now. I have been trying to create a collision for a "top down view" like game.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |