Author Topic: Making a world with unlimited size??!!  (Read 1443 times)

Micboy

  • Jr. Member
  • **
  • Posts: 79
  • Karma: +0/-2
    • View Profile
Making a world with unlimited size??!!
« on: November 14, 2012, 01:54:43 pm »
So, my sprite will always remain in the middle.
However, the world (background) will move down, similar to doodle jump.

If I do this, should I make a container with unlimited height?

DeadSn0wMan

  • Guest
Re: Making a world with unlimited size??!!
« Reply #1 on: November 14, 2012, 03:55:36 pm »
If you mean the world to be your body that you created in BoX2D you need to understand that Box2D and DFSDK are compleatley separete. The Box2D library never knows that your are even using the DFSDK and vice versa you need to code them to interact. To do this you need to get the coordinate for the body that you want your sprite "pasted to" and then apply that coordinate to the actual DFSDK view. You need to do this every frame take a look at the OnTimer function in the code example (with Box2D in it) that the DFSDK team included



Some Box2D tutorials
http://www.iforce2d.net/b2dtut/
« Last Edit: November 14, 2012, 04:03:26 pm by DeadSn0wMan »

Shelbyp67

  • Guest
Re: Making a world with unlimited size??!!
« Reply #2 on: November 16, 2012, 12:07:40 am »
 :P
I think with a little thought you could do this with out the use of Box2D.
This is how I would do it personally...

Imagine a picture like this: Ignore the dots, focus on the '@' and the 'X's
.....X....
...X@X.
.....X....
Let's say '@' is the player, this will always be in the same spot as we are going to build the background(s) dynamically.
Also, each X will be an image of your landscape.
In your code you will need 2 int variables to keep track of our "Clicks" in each direction.
Here I would use:
int xClick = 0, yClick = 0;
Each time your player moves you will need to update these variables, so you will need to use the OnTimer() function.
xClick and yClick will have nothing to do with the actual screen coordinates. (they will but let's keep this simple)
You will need 4 Images for your landscape to move at the same time to make the appearance of the player moving.
Let's say you move down. Obviously your Y coordinate is going to increase, after the image disappears off the screen you will need to update the Y coordinates of it or dynamically change the image after you have increased your xClick and yClick by some amount, typically the amount will be the how ever long it takes for your image to disappear.

Shelbyp67

  • Guest