Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, 1 invisible), 1,086 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Collision problems - demo to help clarify... #93574
10/08/06 04:44
10/08/06 04:44
Joined: Feb 2006
Posts: 371
New England
Rad_Daddy Offline OP
Senior Member
Rad_Daddy  Offline OP
Senior Member

Joined: Feb 2006
Posts: 371
New England
I have been working on a small hobby project in my spare time, and have put together a very small demo of what I want to accomplish with the movement script. It includes strafe movement, forewards and backwards movement, and a view box that moves the camera at a constant rate as a function of time. However, the collision is a little funky, and I would like a little help on the matter.

What I am trying to accomplish is, allowing the player to move freely inside the view_box, but stop the player as soon as it hits the box's bounds. Also, if the player stops all movement, I want the position relative to the box to be maintained, so for instance, if the player stops in the dead centerof the box, he should remain dead center until he/she moves again. My problems are as follows...

1. If the player stops moving, the back of the box slowly closes the distance, and the player goes outside of the box. This seems to be because collision is not applied unless one of the w,a,s,d buttons are pushed (c_move)

2. There seems to be an invisible box in the center of each terrain that, for some reason blocks the player from moving foreward. You can move around it, but it needs to go .

If anyone has any ideas on how to fix either of these problems, I would be very greatful. To help you in every way possible, I have put together this small demo, for you to look at. It is an eye-sore, but it gets the point across. All code is open-source, for easy review. The demo can be found here.

A few notes:

-Terrain tileing system is not implemented.
-View box is visible for testing purposes.
-Code is not commented, because I havent gotten around to it... sorry.

Thank you again, hope the demo + code/explination is enough to get my point across

Regards,
Raddaddy


"Read not to contradict and confute, nor to find talk and discourse, but to weigh and consider." Sir Francis Bacon www.deckscapedesign.com
Re: Collision problems - demo to help clarify... [Re: Rad_Daddy] #93575
10/08/06 10:55
10/08/06 10:55
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
You are moving the view box through adding to its y-position.
Because of this the view box don´t do any collisiondetection and moves through the player. Maybe, you could use "clamp" instead of your view box like this:

clamp(player.x,camera.x-500,camera.x+500);
clamp(player.y,camera.y-700,camera.y+700);

For me there is no Problem with those terrains.
I´m using Version 6.50.2. Maybe it was a Problem with 6.40.5.

Hope this Helps

Re: Collision problems - demo to help clarify... [Re: Slin] #93576
10/08/06 14:38
10/08/06 14:38
Joined: Feb 2006
Posts: 371
New England
Rad_Daddy Offline OP
Senior Member
Rad_Daddy  Offline OP
Senior Member

Joined: Feb 2006
Posts: 371
New England
I am using 6.40, did not know 6.5 was available... anyways, thank you for the tip about clamp, I will look into it further when I get some more free time.

Thanks again,
Raddaddy


"Read not to contradict and confute, nor to find talk and discourse, but to weigh and consider." Sir Francis Bacon www.deckscapedesign.com
Re: Collision problems - demo to help clarify... [Re: Rad_Daddy] #93577
10/09/06 03:25
10/09/06 03:25
Joined: Feb 2006
Posts: 371
New England
Rad_Daddy Offline OP
Senior Member
Rad_Daddy  Offline OP
Senior Member

Joined: Feb 2006
Posts: 371
New England
Sorry, after thinking things through for a few minutes, a few things come to mind. I tried out the clamp function you mentioned, and I have a few questions about how it would work...

1. How can I make the screen move at a constant rate? Would I have to move the terrain rather than the player?

2. If I were to use clamp, the camera could no longer be set at the view_box's coordinates, thus moving the camera wherever the player goes (camera.x = player.x, ect.) How Could I set the camera to look down without actually following the charaacter.

3. As far as clamp is concerned, is it resolution indipendent? I wouldnt want the movement bounds to mess up if the player chooses a different resolution other than my test resolution (1280x800).

Thanks again in advance,
Raddaddy


"Read not to contradict and confute, nor to find talk and discourse, but to weigh and consider." Sir Francis Bacon www.deckscapedesign.com
Re: Collision problems - demo to help clarify... [Re: Rad_Daddy] #93578
10/09/06 13:31
10/09/06 13:31
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
1. Change the cameras x/y position as you did with the view box:
function move_camera()
{
camera.tilt = 90; //turn the camera to the bottom
while(1)
{
camera.y += 1*time_step; //move the camera
wait(1);
}
}

2./3. Use vec_for_screen to get your screens frame:
action player
{
var screen_pos1[3]; //vector definition
var screen_pos2[3]; //vector definition
screen_pos1.z = camera.z-player.z;
screen_pos2.z = camera.z-player.z;
while(1)
{
//movement, ...

screen_pos1.x = 0; //upper left corner of the screen
screen_pos1.y = 0;
vec_for_screen(screen_pos1,camera); //get the world coordinates

screen_pos2.x = screen_size.x; //the screen corner on the right bottom
screen_pos2.y = screen_size.y;
vec_for_screen(screen_pos2,camera); //get the world coordinates

clamp(my.x,screen_pos1.x,screen_pos2.x); //clamp
clamp(my.y,screen_pos1.y,screen_pos2.y); //clamp

wait(1);
}
}


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1