Updating Screen Boundaries

Share your projects and Chipmunk enhancements.
Post Reply
ArtDev
Posts: 3
Joined: Mon Apr 05, 2010 12:28 am
Contact:

Updating Screen Boundaries

Post by ArtDev »

Hey Guys,

I'm working on a game for the iPhone that right now is just a background and some screen boundaries the back ground is currently 640x960 which is twice the size of the iphone screen so that the background has to move around depending on where the user is at...I've got this working the background moves just fine, what I can't get is the screen boundaries to move...they are normal screen boundaries found on the many examples in this forum.


floorBody = cpBodyNew(INFINITY, INFINITY);
leftWallBody = cpBodyNew(INFINITY, INFINITY);
rightWallBody = cpBodyNew(INFINITY, INFINITY);
ceilingBody = cpBodyNew(INFINITY, INFINITY);
cpShape* floorShape = cpSegmentShapeNew(floorBody, cpv(-160,0), cpv(480,0), 1);
floorShape->e = 0.6;
floorShape->u = 0.3;
floorShape->collision_type = 0;
cpSpaceAddShape(space, floorShape);

floorShape = cpSegmentShapeNew(leftWallBody, cpv(-160,0), cpv(-160,960), 1);
floorShape->e = 0.6;
floorShape->u = 0.3;
floorShape->collision_type = 0;
cpSpaceAddShape(space, floorShape);

floorShape = cpSegmentShapeNew(ceilingBody, cpv(-160,960), cpv(480,960), 1);
floorShape->e = 0.6;
floorShape->u = 0.3;
floorShape->collision_type = 0;
cpSpaceAddShape(space, floorShape);

floorShape = cpSegmentShapeNew(rightWallBody, cpv(480,0), cpv(480,960), 1);
floorShape->e = 0.6;
floorShape->u = 0.3;
floorShape->collision_type = 0;
cpSpaceAddShape(space, floorShape);
//End Screen Boundaries

I've read the documentation and it says to not update the body per step but I don't know how else to change the position of the boundaries... if anyone could point me in the right direction I would appreciate it.

Thank you in Advance
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Updating Screen Boundaries

Post by slembcke »

I'm not sure I understand. You want the screen boundaries to move? Like as if the objects were placed inside a box and you were moving the box around with the objects inside of it? Somehow I'm thinking this isn't really what you want though.

You can move the position of a body every frame if you update its velocity to match (position delta divided by time).
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
Tam Toucan
Posts: 141
Joined: Tue Jun 23, 2009 4:26 pm
Contact:

Re: Updating Screen Boundaries

Post by Tam Toucan »

the background has to move around depending on where the user is at
Sounds like he wants to move where the draw position is depending on where the player is. e.g. draw the world so that the user is always in the middle. If that's what you mean then you've got it the wrong way around. You draw the world relative to the player, you don't move the rest of the world. If you think about it the boundary walls stay still and it's the viewpoint (camera if you like) that moves.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest