Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > collision detection
2007-07-28 12:32
Iapetus/Algarbi/Wood

Registered: Dec 2004
Posts: 71
collision detection

Hello all,

I am programming a game and I have started to program the movement of the main character, I am using the bitmap mode, I have created a table where I store the position of obstacles. I read this map to check if the sprite is touching a tile or not to the left, right, up and down. I would like to know what approaches do you use or would use in this case. the protagonist should walk and jump over tiles. Is the collision detection from vic any good?
 
... 2 posts hidden. Click here to view all posts....
 
2007-07-28 13:09
Iapetus/Algarbi/Wood

Registered: Dec 2004
Posts: 71
My problem is that this is not working well

the game tiles are 16x16, the actor is also the same size.

when I read the collision map I divide x and y by 8 and this is working or so it seems.

When I created the routine to move the sprite, if going left I check the collision map with x-1 to see if there is a tile there if it is wont move left if it isn't move one pixel left.
this works

my problem is when jumping and checking underneath to see if there is a tile. I check x, y-2 and x+1, y-2 to check if the sprite is hanging in the "air" and make it fall. This cause the problem that when walking on tiles sometimes it falls between tiles or in the middle of a tile or jumps but instead of staying on a tile falls and only stays there if I jump again. I have checked the values from the col map and it seems to be all ok...

2007-07-28 13:50
Oswald

Registered: Apr 2002
Posts: 5094
maybe it would be better to divide with 16 ?
2007-07-28 13:55
Iapetus/Algarbi/Wood

Registered: Dec 2004
Posts: 71
Quote: maybe it would be better to divide with 16 ?

Can you please elaborate Oswald?

why 16 would work and not 8?
2007-07-28 14:26
Hein

Registered: Apr 2004
Posts: 954
When I was working on a small game, I used a bottom-center point of the sprite (feet) and checked from there. That point always corresponds to a char on screen (or level), that has bits (or combination of bits) set to see what kind of collision is happening. I wouldn't go for the x+1 method, I'd check from current sprite position. If you want to check for enemy collision as well, you'd need the mentioned invisible mask.

VIC sprite/sprite detection can be used to see if sprites are touching, either to refine the collision with a software detection routine, or skip software collision detection.

Good thing about a single point is that the player can move around, even if it's beween two tiles.
2007-07-28 14:37
Iapetus/Algarbi/Wood

Registered: Dec 2004
Posts: 71
Quote: When I was working on a small game, I used a bottom-center point of the sprite (feet) and checked from there. That point always corresponds to a char on screen (or level), that has bits (or combination of bits) set to see what kind of collision is happening. I wouldn't go for the x+1 method, I'd check from current sprite position. If you want to check for enemy collision as well, you'd need the mentioned invisible mask.

VIC sprite/sprite detection can be used to see if sprites are touching, either to refine the collision with a software detection routine, or skip software collision detection.

Good thing about a single point is that the player can move around, even if it's beween two tiles.


My detection map is 1 byte per char(8pixels x 8pixels ).

0SS
0SS
00TT
00TT

for example the S represents the sprite(2x2 chars) the tile is T the same size. 0 is background

I read for exemple under the bottom left S and get 0 and read under the bottom right one and get T so it means that the sprite is on a tile, should not fall.

The sprite moves 1 pixel a time tho, might change it to two.

I guess your method is different, you read from the screen itself to check, not a col map?
2007-07-28 14:50
Hein

Registered: Apr 2004
Posts: 954
I used high nybble of colourmem for collision bits, low bits were poked to colourram. (To save memory) You can have a seperate collision map too, if you need more collision combinations. I didnt need more than 16. Timanthes has the option to create a collision map.

I am wondering if it is wrong if the point between your two SS isnt on a tile, thus making the sprite fall. Once a player is used to it, he will consider it while playing.

Personally, I like platformers that leave some space for making miss-movements. Too tight detection can be quite frustrating.

considering your x+1 or y+2 movements: you gotta be sure to have a flexible movement speed of the sprite. When a sprite falls, gravity takes over, possibly this is y=y+3, what do you do then?
2007-07-28 15:04
Oswald

Registered: Apr 2002
Posts: 5094
algarby, just a fast idea, since your tiles are 16x16, then a collision map is 1/16th of the sprite coordinate resolution and not 1/8th.
2007-07-28 15:10
Iapetus/Algarbi/Wood

Registered: Dec 2004
Posts: 71
Oswald but some tiles can be moved and they can be moved in one byte steps.
2007-07-28 15:13
Oswald

Registered: Apr 2002
Posts: 5094
well allright then. you got your algorythm wrong. try a troughout testing with nailing the problem down to extremely simplistic situations.
2007-07-31 18:20
Iapetus/Algarbi/Wood

Registered: Dec 2004
Posts: 71
It is working now, it was a tiny bug but that made me think that the collision detection routine was wrong, I was not updating one variable somewhere :S grrr thank you guys for the help
Previous - 1 | 2 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Peacemaker/CENSOR/Hi..
Technotron/I-I F
marley
Fungus/Nostalgia
rexbeng
Krill/Plush
REBEL 1/HF
Guests online: 126
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top NTSC-Fixers
1 Pudwerx  (10)
2 Booze  (9.7)
3 Stormbringer  (9.7)
4 Fungus  (9.6)
5 Grim Reaper  (9.3)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.04 sec.