Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Problems with drawing map  (Read 1091 times)

0 Members and 1 Guest are viewing this topic.

Jeckie

  • Newbie
  • *
  • Posts: 22
    • View Profile
    • Email
Problems with drawing map
« on: July 13, 2013, 07:20:58 pm »
I draw a simple picture in gimp 2, little maze.The space where charachter should move I left transparent.
So now I can't make collision with that maze, how would I make a picture and insert it so I can use collision.
While drawing a picture i set its position to 0,0 and size to 800, 600(as the window size).
I think I don't need to paste any code.
Sorry for my bad english.

The Hatchet

  • Full Member
  • ***
  • Posts: 135
    • View Profile
    • Email
Re: Problems with drawing map
« Reply #1 on: July 13, 2013, 07:58:13 pm »
Unfortunately there is no magic way to have a picture just have collision.  There are multiple ways to do collision checking but each way you are going to have to code into your program.  Basically each entity, (Characters, enemies, walls, platforms) is going to have to have a bounding box stored somewhere then when you move your player you need to check to see if its bounding box intersects with the bounding box of anything else.

The way I have my current project set up is I used a tile based map stored in an one dimensional array.  Each element in the array is a tile struct that contains an boolean variable isCollidable and an unsigned int for the type of tile.  When my player moves there is a checkCollisions method that iterates through my array of tiles and for each one that isCollidable == true it check to see if that tile would be colliding with the player.  If there are no collisions returned true then the player is free to move, otherwise he doesnt.

Jeckie

  • Newbie
  • *
  • Posts: 22
    • View Profile
    • Email
Re: Problems with drawing map
« Reply #2 on: July 13, 2013, 10:13:33 pm »
Maybe you didn't understand me, but my question was how to draw larger map.I don't want to draw hundreds of rectangles or something.

 

anything