SRL Archive - Help and Support

object colision ideas? this thread os more of an open discussion then help....


solemn wishes

2006-07-05 13:55:26

hi guys,

Ok here is the deal :eek:, im making a mini-game for scar (could be more than just a minigame) im really enjoying the challenge and had a working keyboard for the game, text display and some other things…..but im having trouble with the object colision….well its not so much trouble as it is un-ethical and untidy to see. The way im currently detecting the object colision is with cords e.g -

  if(y1>209)then
begin
y1:= y1 - 1;
end;

know this works fine but its very time conusiming and as i said horrible to look at. Does anyone else have any ideas?

o here is a pic of the map i just made



thx :)

Nazgand

2006-07-05 14:36:44

how about this
type Object:record;
x,y,type,brain,dir,act:integer;
end;

x and y are coords,
type,dir,act are for wich pic
brain is for what it does(monster,npc,your mario guy,a powerup,teleport)

that way you could have an array of all the objects on the screen and have a procedure that checks em all for the coords and bitmap size to see it they overlap
also youd have to heave a procedure to draw everything in the array

solemn wishes

2006-07-05 17:18:43

to save memory and loading time (scar takes a logn time to load images sometimes) the images that you see are just one whole image. My anitial idea of using specified cords…..ive went ahead with and its not as bad as i thought. I've all ready been able to add collision to the table, chest and all 4 walls….in the time frame of about 10 mins :o but im still open to surgestions….

*update* battle mode nearly done :)

Avaphi

2006-07-05 17:27:15

Perhaps use a procedure/function that deals with distance, And when they come within the distance it triggers the fighting :D

XxKanexX

2006-07-06 03:03:01

Use a TPointarray to keep track of where the main character is standing (From top Left corner). Then, using the size of the character:


if (Char[0].x >= Monster[0].x) and (Char[0].y >= Monster[0].y) and (Char[0].x + Sizex <= Monster[0].x + MonSizex) and (Char[0].y + Sizey <= Monster[0].y + MonSizey) then
Writeln('Character is on top of the monster.');

Renax

2006-07-06 10:01:37

you could load an array of un-walkable tiles at the start of each new area you enter then you would do they check during runtime when the walk command is issued.

i'm guessing your using the arrow keys, so something similar to this.


function ProccessWalkCommand: boolean;
begin
if (RightKeyDown) then
begin
if RightPixelLoc = 'unwalkable' then
PlaySound('Error')
else
begin
ProccessMove;
Result:= True;
end;
end;
end;


you would include the the other keys this is just an example, and for checking the tiles you would just check to see if the specfied tile was in the un-walkable array.