   My game project , Updated regulerly
  this is my Game project,still under work Using XNA 3.1 for this one - currently in the process of adding enemies and death seqences for them and for the player, also am working on structuring some more levels :).here is my projectwww.mediafire.com/?zqjzdow2izn - version 0.1 www.mediafire.com/?wwmotynwiej - version 0.2www.mediafire.com/?yt3uzojmjez - version 0.3 - working collision, dieing enemies and some changes to shooting texturewww.mediafire.com/?xmivotfcnwy - Version 0.4Edit// i noticed Version 0.4 was not the correct one so i posted a new link for the real versionplease, if you may,Check it out, any questions and suggestions are welcomedif you try to run it, please include 4 sound files of your own into the Sound folder there or exclude it from the project.about the project:basically its a 2D shooter, like MetualSlug or Megaman.what i am trying to accomplish in it is basic 2D shooter gameplay with about 2 -3 levels with 3-4 different types of enemies .[Edited by - genyagilin on June 8, 2010 7:50:55 AM]
  You are asking us to debug your program for you. Think about the question with the roles reversed? I've some lovely code you could debug for me? [grin]The best way to get answers is to write a good question. A good way to approach writing such a question is to write what you have tried. You haven't even described the behaviour of your program, just that it has "problems".Put the smallest possible burden on your readers. Don't link to an entire project, post the relevant code. The collision detection class sounds like a likely candidate.   ;  thaמל you for your note about this ,i really didnt think streight forword posting my question like that.Collision Check Does the Following, it gets and updates lists of Rectanglesand than using, for ( ) loops, it Checks those lists for collisions between those rectangles, my problem is that as far as i can see Shots fired at me by enemies , as soon as they collide with my charecter , stay collided with him regardless of my charecters whereabouts.and i just cannot see where is the problem with my code.Here is my CollisionCheck Method inside of the CollisionDetection Class. private void CollisionCheck()   {  for (int i = 0; i < EnemieShotsRec.Count(); i++)  { if (Dude.Intersects(EnemieShotsRec) == false) {DudeCollShot = false; } if (Dude.Intersects(EnemieShotsRec)) {DudeCollShot = true;i = EnemieShotsRec.Count(); }  }  for (int i = 0; i < TileRec.Count; i++)  { if (Dude.Intersects(TileRec) == false) {DudeCollTile = false; } if (Dude.Intersects(TileRec)) {//if (Dude.Bottom >= TileRec.Top )//{//    DudeCollTile = true;//    i = TileRec.Count();//}if (Dude.Bottom > TileRec.Top && Math.Abs(Dude.Bottom - TileRec.Top) < 20){    DudeCollTile = true;    i = TileRec.Count();} }  }  for (int i = 0; i < EnemiesRec.Count; i++)  {// if (Math.Abs(Dude.Right - EnemiesRec.Left) < 3 != false) if (Dude.Intersects(EnemiesRec) !=  false) {Game1.Enemies[0].StubbingDistance = false;DudeCollEnemie = false; }// if (Math.Abs(Dude.Right - EnemiesRec.Left) < 0) if (Dude.Intersects(EnemiesRec) ) {DudeCollEnemie = true;Game1.Enemies.StubbingDistance = true; }  }  for (int i = 0; i < EnemiesRec.Count; i++)  { for (int j = 0; j <PlayerShotsRec.Count; j++) {if (EnemiesRec.Intersects(PlayerShotsRec[j])){    EnemieCollShot = true;}//else//    EnemieCollShot = false; }  }    }ill be happy to answear any questions about this method ,for the whole class please reffer to my project download link above[Edited by - genyagilin on June 5, 2010 11:36:48 PM];Quote:basically its a 2D shooter, like metualSlug or megamanThe genre is rather platformer (a.k.a jump'n'run). This is not easy to program. To have a grasp of the complexity take a look at a recent thread concerning basic navigation/collision in a platformer: Set me straight on platformer collision detection.I'm telling you this, because looking at your code I think you are too ambitious if you want to get everything working from the start. You already got several entities (ememies and shots for both players and enemies) and tiling for your level. To get the collision detection right even with a few entities shows one thing: Your design is flawed or hard to debug or both.I agree with rip-off, I won't compile your project and debug either, sorry.I'd like to give you some hints, though:Why do have always a pair of lists, one for your entities and one for the rectangles ? This not only complicates/bloats the code, but can likely be corrupted, i.e. by wrong indexing. You already have got a rectangle property in your TheEnemies class (which I'd rather call Enemy by the way, it represents one enemy). Take that for your collision routine, if it's not the dynamic rectangle (haven't check) then add a new property which will calculate it.That your collision is 'sticky' might come from the fact that you don't remove the shot them from your shot-list (haven't checked though).Other than that: Do one step at a time!- start with your player only (!), just drawing, no tiles, no enemies, no shots- make your player movable (by keyboard, mouse) in a simple way (up, down, left, right)- put two entities on your screen (no lists yet!) make one your movable player and check for the one (!) collision that can occur. - Give you collision a visual feedback, for instance drawing transparent rectangles or tinting your sprites. A visual feedback is always handy. You could even consider drawing your bounding rectangles for later debugging.- do it again with a list, the list containing one entity only.- fill the list with two enemies and make sure your collision detection is working. Increase the amount further.- remove collided enemies from the listand so on.Hope that helpsPS: Ah yeah, and use source tags when posting code.   ;  whats Source tags???i do remove the shots from the lists,my collision with the tiles is actually working prrety well my,i edited my project today and added another enemie to it , one shoots and one Stubbs,my problem currently is a problematic use of computer resources,i figured out my way of coding the collision with everything is not efficient,though i cannot think of any other idea for it, and thats actually after checking this forum for a bit.one thing i am missing right now is an idea of how to make my code more efficientespeccialy the Collision Detection part of it.for now as you can see from my previous post i use lots of lists and for () loops to check for collision, and whould appreciate a good advise dealing with my prob.and unbird thanks for your comments, they did help a bit , though i already did most of what you wrote here including adding some enemies and removing collided enemies .thanks agin :)also, here is a fresh upload of my project,so that any of you who are interested could look at my progress or something www.mediafire.com/?wwmotynwiej[Edited by - genyagilin on June 6, 2010 5:29:41 PM];  So you actually solved your collision handling logic ? What was the problem and how did you fix it ?Now it's efficiency. Well, for a start, you actually test each possible collision twice, unnecessary:    for (int i = 0; i < EnemieShotsRec.Count(); i++)    {   if (Dude.Intersects(EnemieShotsRec) == false)   {  DudeCollShot = false;   }   if (Dude.Intersects(EnemieShotsRec))   {  DudeCollShot = true;  i = EnemieShotsRec.Count();   }    }can be translated to    DudeCollShot = false;    for (int i = 0; i < EnemieShotsRec.Count(); i++)    {   if (Dude.Intersects(EnemieShotsRec))   {  DudeCollShot = true;  break;   }    }(here I used source tags, by the way)But that's just a detail. Efficient collision systems apply special structures like quad-trees, grids or bounding volume hierarchies (google these terms!). You will need them if your lists get larger since your double loop at the end of your method has a so-called O(n^2) time complexity (google for big-O-notation). In English: This behaves bad for large lists.But I bet it's your drawing: You draw your sprite with a XNA SpriteBatch individually, but it's not called a batch for nothing. Enclose all (or at least sprites of the same type/texture/whatever) drawing in the spriteBatch.Begin/End. This is how fast rendering works here: Collect what you want to draw and send it together. (Explanation is very vague, I know).But it can also be anything else. You don't know until you have located your bottleneck: Switch on/off parts of your code by commenting out (or even switch at runtime) or use a profiler.   ;  oh my, didint see that solution you offered actually, thank you for that :)also , i found a memory leek after wich i have fixed and was causing all of my trouble .i didnt reset my lists propely causing some lists to become very long and taking a lot of memory.my lists for this game arent that big for me to change the code logic right now, as i did think about what you said prior to coding or else i whould have cunsolted first and than whould have started my coding.as for where i currently stand, basically now i am adding a Dieing sequence for my enemies, also some Textures for more enemies .my Current problem is with the comps ai, and a little bug with getting of tile ledges as my falling logic stopps working there even though it entres a falling loop(wich i will post in the end of this response)to answear your question , my collision logic worked from the begining, the problem was not with tiles but with my player recondnising a collision with enemy shots and enemies recondnising collisions with players shots wich i solved by debbugging , while i debbuged i noticed i only check for shots of enemy number 1 , and never for others wich was also true for enemies with my shots.so to my current probmy player does not accelerate downwords if he runs off a Tile,here is my logic for the Gravity and jumping:i have set for hours on this bug buit i cant seem to understaned why it happenes as while debbuging i the gravity loop always is working :( private void UpdateJump(KeyboardState keyboard)   {   if (keyboard.IsKeyDown(Keys.Space) == true && isJumping == false) {isJumping = true;    Jump(); } if (Game1.collisiondetection.DudeCollTile == false) {Speed.Y += Consts.FallAcc;  } else if (Game1.collisiondetection.DudeCollTile && Speed.Y < 0 ) {Speed.Y = 0;isJumping = false;CurrentState = State.Standing; }   }  private void Jump()   {  if (CurrentState != State.Jumping)  {  CurrentState = State.Jumping; Direction.Y = Consts.MoveUp; Speed.Y =(float)Consts.SpeedDudeY;  }   } [Edited by - genyagilin on June 7, 2010 4:11:22 AM];  Glad to hear you found the collision bugs [smile]. And sorry, yeah, should have seen that in your code snipped that you just recorded if a collision occurs, but not with what.For your jumping problem. The state logic and speed handling looks rather proper to me. First I consideredif (Game1.collisiondetection.DudeCollTile && Speed.Y < 0 )a bit suspicious but actually Consts.FallAcc is negative, too (had to look into your downloaded code, though). And since you are saying the error does NOT appear when debugging, well, then it's really nasty. Can be an indication that the error is not in the code you provided, so we are both searching in the dark.Can only give you general hints. Make sure your state machine is consistent and cannot get stuck (always standing for instance). Is this the only place where you change the state ?Maybe logging or even a graphical feedback is helpful: Draw your entity properties above your sprites (velocity as an arrow, states as text for instance), and slow down animation time. If the latter is not possible, stop the update entirely and advance step by step (frame by frame).   ;  :) thats why i posted my code in the first place actually hhhas to your suggestions, i have trully tried everything, i just cant figure out why it gets stuck, ill try sitting on it with my paps or somethin.but i do think the problem should be with the States of the Player, will check into that.thanks for the help though , its rather appreciated.well gonna focuse on death sequences today, as i think small bugs like the one i mentioned before can be left for later on as i should use my time for more urgent coding problems.currently , i have vreated a new event wich handles death sequence, as soon as a boolet of the players, hits the enemie, its alpha should blend until its transperent and than dissapear from the map entirely.the problem currently the death event somehow affects all enemies at once, and thats but i will try solving on today.www.mediafire.com/?yt3uzojmjez - version 0.3 - working collision, dieing enemies and some changes to shooting texture, also fixed a memory leek - have a look at it unbird you helped me get so far :)also just finished Death Sequences , and added a nice shooting texture to the end of the cannon while shooting .now i am working on Players health bar and damage to player + adding some enemies to my game as my axe wielding tribe man are missing some firepower :)also am trying to think if i should add Tile Collision and gravity for enemiesand maybe even a jump protocol or something,do you think its a good addition to the code? or will it be unnoticble during gameplay.[Edited by - genyagilin on June 7, 2010 6:57:12 AM];  just wanted to update my status on the project,today i finished menues for my game, There is an option menu, an about Screen and a Start and Exit Options to choose from.also have made Players healthbar workable, and will finish with death seqences for him in a day or too at most , by than hopefully will have some more enemies and textures for them.Heres a fresh Download link, www.mediafire.com/?xmivotfcnwyTo run the game you must delete all songs from the song directory, from within the project.Press F10 for the Menu to appear, You can choose weapons with Numpad 1-3,jump with Space key,toggle FullScreen withing the Option menu or with the Home key,Shoot with the G key, move with Right and Left arrows.Any comments or question about code logic or anything else are welcomed.[Edited by - genyagilin on June 8, 2010 7:21:05 AM]