Jump to content
  • Advertisement

Darren Johnson

Member
  • Content Count

    6
  • Joined

  • Last visited

Community Reputation

108 Neutral

About Darren Johnson

  • Rank
    Newbie
  1. Darren Johnson

    Handling collision and the removal of objects

    Thanks guys.
  2. I am in the process of building a simple shooter game. I am currently making a destructible class which will be tasked with handling the removal of objects from the game which have been destroyed by bullets fired. I think i know how to go about this as I will need to: Get the index of the most recently fired bullet Get the positions of the objects in the room Check for collisions between the bullet and those objects. I just don't know how to implement this. Also is there anything I am missing? I have a list of bullets in a bulletManager class, how do I access or call the most recently fired bullet? Here is the destructible class: using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System.Collections.Generic; namespace MainCharacter { class Destructible : BaseCollideable { Texture2D texture; Vector2 position; int health; bool destroyed = false; /// <summary> /// Creates a new destructible object. /// </summary> /// <param name="tex">The textures of the object.</param> /// <param name="pos">The position of the object.</param> /// <param name="hel">The health of the object.</param> /// <param name="dst">The status of the object.</param> public Destructible(Texture2D tex, Vector2 pos, int hel, bool dst) : base(tex) { texture = tex; position = pos; health = hel; destroyed = dst; } /// <summary> /// Updates the destructible object. /// </summary> public override void Update() { if (destroyed == true) { // Remove bullet // Remove texture // Deposit a power up in its place } base.Update(); } public void Destroyed() { // If bullet collides with object: // destroyed = true // else // destroyed = false } public void GetBulletIndex() { // Get the index of the most recent bullet fired } public void GetObjectPositions() { // Get the positions of objects in the current room } public void CheckForCollisions() { // Check for collisions between the latest // bullet fired and the object positions } public Texture2D Texture { get { return texture; } } public Vector2 Position { get { return position; } } public int Health { get { return health; } } public bool Destroyed { get { return destroyed; } } } } Can anyone help?
  3. Darren Johnson

    Recursive Methods

    I am having particular problems with the FillCell method in the Form1.cs in the TileEngine class. public void FillCell(int x, int y, int desiredIndex) { int oldIndex = currentLayer.GetCellIndex(x, y); currentLayer.SetCellIndex(x, y, desiredIndex); if (x > 0 && currentLayer.GetCellIndex(x - 1, y) == oldIndex) FillCell(x - 1, y, desiredIndex); if (x < currentLayer.Width - 1 && currentLayer.GetCellIndex(x + 1, y) == oldIndex) FillCell(x + 1, y, desiredIndex); if (y > 0 && currentLayer.GetCellIndex(x, y - 1) == oldIndex) FillCell(x, y - 1, desiredIndex); if (y < currentLayer.Height - 1 && currentLayer.GetCellIndex(x, y + 1) == oldIndex) FillCell(x, y + 1, desiredIndex); } It just seems to be finding tiles outside of the array all of the time. Which breaks the program. The fill feature seems to be used again in the next few videos, so I can';t move on until it works.
  4. Darren Johnson

    Recursive Methods

    Hi, I am currently working on Nick Gravelyn's tile editor but I am stuck on episode 5 (Recursive Methods). Would you be able to point out to me where I am going wrong? I seem to get out of bounds exception errors when I try to use the 'fill' option. The error is quite different than the one he highlights in the video. I cannot progress with these tutorials (which I would like to) until I resolve this. My project is here, if you wish to take a look at it: https://skydrive.liv...89BB32BAF8D!134 I would greatly appreciate any help you can give to me. Thanks for taking the time to read this. Regards, Darren
  5. Darren Johnson

    Nick Gravelyn's Tile Editor

    I have looked at those WinForms samples. I imported bought the 3.1 and 4.0 versions (seperately of course). I have also tried converting the problem issues using this cheatsheet, but it has not got me by this problem yet.
  6. Darren Johnson

    Nick Gravelyn's Tile Editor

    Hi, Would someone be able to help me? I am working through Nick Gravelyn's Tile Editor tutorials on youtube. While I know they were created a few years ago, I was going ok until tutorial 3B part 1. Now I have 9 errors which I cannot get around. They are centred around the 3 classes you import during this tutorial and the fact that I cannot develop the windows form as the link to the tile editor will not display in the toolbox. Can anyone point out a way past this? Darren Video: [media][/media] Code: https://skydrive.liv...!126&parid=root
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!