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?
2007-07-28 12:45
cadaver

Registered: Feb 2002
Posts: 1154
I wouldn't rely on VIC collision, it raises hell anyway when you get into sprite multiplexing.

Since I've used character mode I define a collision byte for each char of the background charset, where different bits denote different kinds of scenery/obstacles (for example bit 0 = can walk on).

The chars could be checked either directly from screen memory (faster) or from the level map (slower, but gives possibility of offscreen collision detection).

If you build your bitmap screen from chars or blocks then the latter method, checking from levelmap, could be applicable to you, but if the backgrounds are kind of "freeform" then it doesn't apply..
2007-07-28 12:47
Radiant

Registered: Sep 2004
Posts: 639
I'd check the sprite's bounding box against the tile positions, to determine if there's a collision and where. Lacking tiles, I'd go for a similar approach with an invisible collision mask, much like you've done it seems. The VIC's collision detection is better left alone unless you're doing a very simple game.
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: 5031
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: 5031
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: 5031
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
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
El Jefe/Slackers^sidD
taper/ΤRIΛD
Flavioweb/🇮🇹HF..
Digger/Elysium
Perff/No Name
Asthor/Exlusive ON
Tom-Cat/Nostalgia
Matt
Mike
kbs/Pht/Lxt
The Syndrom/TIA/Pret..
JackAsser/Booze Design
Isildur/Samar
Guests online: 125
Top Demos
1 Next Level  (9.7)
2 Mojo  (9.7)
3 13:37  (9.7)
4 Coma Light 13  (9.7)
5 Edge of Disgrace  (9.7)
6 No Bounds  (9.6)
7 Aliens in Wonderland  (9.6)
8 Comaland 100%  (9.6)
9 Uncensored  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 It's More Fun to Com..  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Rainbow Connection  (9.5)
8 Dawnfall V1.1  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Birth of a Flower  (9.5)
Top Groups
1 Nostalgia  (9.4)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 SHAPE  (9.3)
Top Logo Graphicians
1 Sander  (9.9)
2 Facet  (9.5)
3 Mermaid  (9.4)
4 Pal  (9.4)
5 Shine  (9.3)

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