Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

123 Neutral

About crohnsandme

  • Rank
  1. crohnsandme

    is the size of my tile messing up the collision?

    ok forget all above here is my new problem....   i am only dealing with single tiles on floor level so i know i maybe need stricter if statments once i jump up more levels but i can jump on top of a tile and both the left and right collision work for the sides of tile   coding:   //topoff                       if (character.playerPosition.Y <= tile.Rectangle.Top &&                          character.playerPosition.X + (character.rectangle.Width / 2) >= tile.Rectangle.X + (tile.Rectangle.Width/5) &&                         character.playerPosition.X + (character.rectangle.Width / 2) <= tile.Rectangle.Right+70)                     {                                                      character.playerPosition.Y = tile.Rectangle.Y - 64;                             character.velocity.Y = 0f;                             character.hasJumped = false;                                                                                                        }                       //leave top of tile                     else                         if (character.playerPosition.Y <= tile.Rectangle.Top &&                          character.playerPosition.X + (character.rectangle.Width / 2) <= tile.Rectangle.X)                         character.hasJumped = true;                     else                             if (character.playerPosition.Y <= tile.Rectangle.Top &&                              character.playerPosition.X + (character.rectangle.Width / 2) >= tile.Rectangle.Right)                                 character.hasJumped = true;                                                                                                                                 //touch left                       if (character.playerPosition.X + 64 >= tile.Rectangle.X &&                         character.rectangle.Y  >= tile.Rectangle.Y &&                         character.rectangle.Left <= tile.Rectangle.Left)                     {                         character.playerPosition.X = tile.Rectangle.Left - 64;                     }                       //touch right                       if (character.playerPosition.X  >= tile.Rectangle.Left  &&                         character.playerPosition.X <= tile.Rectangle.Right+80&&                         character.rectangle.Y >= tile.Rectangle.Y                          )                     {                         character.playerPosition.X = tile.Rectangle.Right+80;                     }     but now when my character is on top of the tile it wont jump, i think i does attempt to jump but because of the on top if statement it always throws it back to the same position?   i tried saying if character.rectangle.bottom == tile.rectangle.top but i noticed when debugging that they never are the same? which i think maybe my problem?
  2. crohnsandme

    is the size of my tile messing up the collision?

    does anyone have any tutorials on collision with tiles?  my player touching left of a tile works fine here is that code     if (character.playerPosition.X + 64 >= tile.Rectangle.X &&                         character.rectangle.Y  >= tile.Rectangle.Y &&                         character.rectangle.Left <= tile.Rectangle.Left)                     {                         character.playerPosition.X = tile.Rectangle.Left - 64;                     }   and when i switch a few things round to do the right of the tiles it shoots me to the very right of all my tiles   if (character.playerPosition.X  <= tile.Rectangle.X + tile.Rectangle.Width  &&                         character.rectangle.Y >= tile.Rectangle.Y &&                         character.rectangle.Left <= tile.Rectangle.Left)                     {                         character.playerPosition.X = tile.Rectangle.X + tile.Rectangle.Width;                     }   any chance anyone can help me work this out?im happy with the on top and underneath but the right is causing me problems
  3. crohnsandme

    is the size of my tile messing up the collision?

    ok i admit that sounds confusing but could be because i been staring at the computer for last few hours , i think i can see where my problem is.... i am using an 2d array to create my map not a file(maybe my first mistake?)   here is an example of the map i using atm to test collision                   {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},                 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},                 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},                 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},                 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},                 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},                 {0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,0,0},                 {0,0,0,0,0,0,0,0,0,0,0,2,2,1,2,2,2,2,2,2},                  {0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,2},                 {0,0,0,0,1,0,0,0,1,0,0,2,2,2,2,2,2,2,2,2},                             }, 90);   now in the tutorial i used they used 64 as that final value for the size of width and height but then my camera has the map zoomed out far but when i changed it to 90 it made the tiles closer to the screen, but thew now when it comes to the collision the values are all weird, so my tiles width and height is 90x90 but my character is 128x128... i  need to try work out the if statements for the collision.... so frustrating , guess this is the problem following an tutorial and then changing things it forces you to learn and understand each line of code to find the problems guess thats supposed to be part of the fun lol
  4. crohnsandme

    is the size of my tile messing up the collision?

    yes, basically when i have the collision for top,bottom,left and right i jump onto a tile and i end up half way up screen lol i tried using fixed numbers to work out whats happening but i must be missing something , also when it shoots half way up screen it will slowly fall down very slowly, i will relook over the coding and if im struggling by tonight i will post what i have got up and see whats wrong :)   thanks
  5. crohnsandme

    best beginner book Dirextx game programming?

    ok well seeing as we will be using this at university im guessing ill go get lunas book and then i can read the other also for the things that are missed out of lunas book?   thanks guys/girls
  6. hi all, so i am trying to do a tile map and get my character to collide with them and jump from one to another etc, my character is 128,128px but my tiles that i found online (free) are only 32x32px , will this cause problems when doing collision?   the collision theory i am following is 2 rectangles one for character(r1) and one for each tile(r2)    this is example for if its touching top of the other            if    (r1.Bottom >= r2.Top - 1 &&                 r1.Bottom <= r2.Top + (r2.Height / 2) &&                 r1.Right >= r2.Left &&                 r1.Left <= r2.Right );   now am i right in thinking surely if my rectangle for character is 128,128 and the rectangle for each tile is only 32,32 this collision isnt going to work (which it doesnt atm) ? how do you normally work this out? my character looks good on screen 1600x900px at 128x128... so should i make tiles bigger or shouldnt it matter?
  7. hi all, so i am slowly moving onto to 3D and know at university i will be using directx so i want to get a little headstart learn the basics and be comfortable using the tools needed, i see a few different books for beginners with directx just thought is there any specific ones i should look for that will do me well? thanks
  8. crohnsandme

    new to graphics surely this isnt pixel art?

    oh no i am making a game with the resolution 1600x900 (for now it will eventually have an fullscreen mode) so the character i am using at the moment is 125x125px so maybe use the same? for now i am tinkering with drawing trying to make what i want but using sprites from heli attack 3 for now :) if worst comes i can still use these sprites as its only for educational and a showpiece to show my uni what i know already but i would like to say "ye this is all my own artwork also" :)
  9. crohnsandme

    trying to get camera working

    hahahaha omg it was so obvious after i wrote the previous post i basically had said what i needed to do lol :) now onto creating a  tiled map so i can take advantage of the working camera :)
  10. crohnsandme

    trying to get camera working

    ok this is annoying me now i decided because the only enemies for now will be same enemiy texture in list its pointless making a complex sprite manager when its only a 1 player simple game, so back to the camera problem   if i remove the sprite.begin and end from the main class none of the menus are drawn, i have tried a few different ways trying to end before the next begin and having no luck , here is the MAIN class code     protected override void Draw(GameTime gameTime)         {             GraphicsDevice.Clear(Color.CornflowerBlue);               spriteBatch.Begin();             switch (CurrentGameState)             {                 case GameState.Playing:                      actionScene.Draw(spriteBatch);//spriteBatch.Draw(actionBackTexture, new Rectangle(0, 0, screenWidth, screenHeight), Color.White);                      break;                   case GameState.MainMenu:                     spriteBatch.Draw(backgroundTexture, new Rectangle(0, 0, screenWidth, screenHeight), Color.White);                     spriteBatch.Draw(crosshairTexture,crosshairRect,null,Color.White,rotation,origin,SpriteEffects.None,0);                     break;                 case GameState.Options:                     spriteBatch.Draw(optionsTexture, new Rectangle(0, 0, screenWidth, screenHeight), Color.White);                     break;             }             spriteBatch.End();             base.Draw(gameTime);                      }   and then here is the main actionscene where the player,enemies,bullets everything in game is drawn etc    public void Draw(SpriteBatch spriteBatch)         {             //spriteBatch.Begin(SpriteSortMode.Deferred,               //  BlendState.AlphaBlend,                 //null, null, null, null,                 //transform);             spriteBatch.Draw(backgroundTexture,backgroundRect,Color.White);             character.Draw(spriteBatch);             crossHair.Draw(spriteBatch);               if (firing)             {                 foreach (Bullet bullet in bulletList)                     bullet.Draw(spriteBatch);             }         }   ye at the moment there are no enemies, nor map tiles etc so for now its just the player the crosshair and bullets drawn   can someone help me find what/where to put the camera sprite.begin please thanks
  11. crohnsandme

    new to graphics surely this isnt pixel art?

    yes i sumbled across a copy of illustrator :D i like this and think i like using the mouse for the dragging the lines etc so going to stick with the mouse and practice :) one last thing and i guess this shouldnt matter because you can scale vector art but whats an usual size canvas to work on say a character sprite?
  12. crohnsandme

    trying to understand gamestate,enum and main menu

    thanks yes atm the moment i have gone back to create a sprite manager (which i just learnt) so its helping me make sure i understand it proerly , then i will go back to focusing on getting the camera to follow camera plus side scrolling, then finally create a map then i will be happy , i want to then look at perpixelcollision plus getting enemies into the game maybe attacking with swords instead of bullets everywhere plus it helps show the perpixelcollision :) so alot of work to do i hope to try spend a few hours a day on this before university starts in september so i have a decent background in making the 2d games so i can then focu on the 3D games
  13. crohnsandme

    trying to get camera working

    ahh yes that is fine , at the moment i have took a step back and decided to clean the coding up of what i have so far ie, create a spritemanager to make it easier for others to read my code and help me learn more about making a spritemanager, but soon as i am sorted with that i will be back to look at the camera problem im glad its not a major problem and seems to be easy enough to sort out :)   thanks for looking
  14. hi all , so i have a main class   HeliClass    which holds my different scenes   then i have an actionscene which holds all my players , weapons,enemies etc   i have created a camera class and then i have created a new camera within my player class (i have also tried to create it within the actual actionscene) but i think its all ok apart from when it comes to the draw method when i have to include the camera within the spritebatch.begin(.............) but i am getting an error because obviously i have an spritebatch.begin in the main class which holds  the different scenes.... so i tried writing a new spritebatch.begin in the player/actionscene but getting the error obviously i cant begin a new one until the end has been called     can anyone help me with this problem. if needed to see any code i will paste it in if needed. i just wondered if this is a common problem people get?   i cant see how to create the new camera in the main heliClass because i need to pass the character values which are created within the player/action class?
  15. crohnsandme

    trying to understand gamestate,enum and main menu

    thanks for that link spiro but i will be honest i am a beginner, learning c# for the last 2-3 months from books on my own so looking at that C++ is very intimidating as i cant follow it 100% i understand to use polymorphism instead of the switch cases but as for now i feel i would be jumping ahead and not understanding things if i was to try and implement what you are suggesting i expect once i have more confidence and experience i will learn better ways etc i suppose if i had knowledge of C++ i would understand that tutorial better and would be able to follow what they are saying 
  • 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!