Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user tubesockor ! (Registered 2024-05-12) 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: 5025
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: 933
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: 933
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: 5025
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: 5025
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
zscs
Dr. Doom/RAD
Scooby/G★P/Light
cg/Censor Design
www.gb64.com
Bitbreaker/Performers
Mason/Unicess
Electric/Extend
mutetus/Ald ^ Ons
MCM/ONSLAUGHT
Chico/Civitas
eryngi
Lenyn/Triumwyrat
Guests online: 140
Top Demos
1 13:37  (9.8)
2 Next Level  (9.8)
3 Mojo  (9.7)
4 Coma Light 13  (9.7)
5 Edge of Disgrace  (9.6)
6 Comaland 100%  (9.6)
7 No Bounds  (9.6)
8 Uncensored  (9.6)
9 Wonderland XIV  (9.6)
10 Multiverse 100%  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Layers  (9.6)
5 Copper Booze  (9.5)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Rainbow Connection  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Booze Design  (9.3)
3 Nostalgia  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Original Suppliers
1 Black Beard  (9.7)
2 Derbyshire Ram  (9.5)
3 hedning  (9.2)
4 Baracuda  (9.1)
5 Jazzcat  (8.6)

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