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

Author Topic: background obstacles in 2D side scroller game  (Read 1826 times)

0 Members and 1 Guest are viewing this topic.

lorence30

  • Full Member
  • ***
  • Posts: 124
    • View Profile
    • Email
background obstacles in 2D side scroller game
« on: June 02, 2015, 07:43:06 pm »
Hello, im making my 2D side scroller game. (super mario)

sorry for my english.

i dont know if i did it right,

first ,if mario is in the middle position and then he moves forward the "background will move", while background is moving mario will still be in the middle position until he moves back.

second, how about the obstacles that arent yet visible in the screen? should i make the background to, like, window.getSize().x * 50000 pixels? and then put the obstacles and the enemies there at the beginning of the program? and if  theyre already visible in screen i will start to make them move?
or any ideas?
thanks.

 
« Last Edit: June 02, 2015, 07:45:57 pm by lorence30 »

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: background obstacles in 2D side scroller game
« Reply #1 on: June 02, 2015, 07:46:17 pm »
For something blocky like mario, I'd suggest using a 2d array for collision detection and having lots of images which are each the default size of the window, then either displaying one or two of them, depending on how far you'e scrolled.Basically, you draw the whole level as one image, then load a rectangle for each amount that is displayable at a time. Either that or use a sprite/texture per type of block.

lorence30

  • Full Member
  • ***
  • Posts: 124
    • View Profile
    • Email
Re: background obstacles in 2D side scroller game
« Reply #2 on: June 02, 2015, 08:04:40 pm »
 
Quote
I'd suggest using a 2d array for collision detection
yea, i always use 2d array fo collision detection for any games

 

Quote
and having lots of images which are each the default size of the window, then either displaying one or two of them, depending on how far you'e scrolled.Basically, you draw the whole level as one image, then load a rectangle for each amount that is displayable at a time. Either that or use a sprite/texture per type of block.

okay thanks for idea

 

anything