![]() |
![]() |
#1 |
Fernando Cabrera
Join Date: Oct 2013
Location: Spain
Posts: 106
|
Collision detection: 2 doubts
Hi all,
I'm working on an Arkanoid-type game for OCS, just for learning the best techniques for every kind of task. So it's time for some doubts about collision detection ![]() 1) Check keyboard. 2) Move pad. 3) Move ball. 4) Check collisions between 4.1) Ball and pad. 4.2) Ball and walls. 4.3) Pad and walls. For points 4.2 and 4.3 there's no problem as I just do collision detection by software and backtrack in case of the ball or pad penetrating the walls. Problem is with point 4.1. I have collision detection ball vs pad enabled by hardware. What happens is that I move the ball in point 3 so, if it's moving more than 1 pixel per frame the sprite can penetrate a few pixels into the pad. In point 4.1 I do backtracking to push the ball back and out of the pad but it's too late as point 3 has already drawn the sprite. So you can notice that the ball "enters" the pad and goes out quickly after that. Any ideas about how this should be managed? Another question about collision between the ball or pad and the walls. As I said, I'm doing that by software. Do you think that's the best way or should I enable collision between the sprites and the playfield? In that case I guess I should use the bits MVBPx in CLXCON register to make the collision happen only when the ball hits certain parts of the playfield (the borders in this case). This implies redesigning the image used for the playfield and, probably, the palette. Am I right? Thanks in advance! |
![]() |
![]() |
#2 | ||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,537
|
Quote:
Also remember that the collision is not detected before the hardware has displayed the sprites, so you have to wait until the end of the frame (or beginning of the next one), before reading CLXDAT. Quote:
In games a collision detection must rarely be that precise. A player won't notice if the collision happens one pixel too early or too late. |
||
![]() |
![]() |
#3 | |
Fernando Cabrera
Join Date: Oct 2013
Location: Spain
Posts: 106
|
Quote:
![]() |
|
![]() |
![]() |
#4 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,025
|
Perhaps you could first move the ball and then the pad so that the pad goes into the ball and not the other way round. The player might consider the ball to be elastic and the pad may deform the ball a bit during a hit.
|
![]() |
![]() |
#5 | |
Fernando Cabrera
Join Date: Oct 2013
Location: Spain
Posts: 106
|
Quote:
Thanks for your answer! ![]() |
|
![]() |
![]() |
#6 |
Glastonbridge Software
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,243
|
I would do this using maths - line intersections. You can treat the ball as exactly circular rather than using bounding boxes, and detect even collisions where the ball is moving so fast it would go straight through the bat between frames.
|
![]() |
![]() |
#7 |
Beyond Mutton
Join Date: Mar 2011
Location: North West, UK
Age: 52
Posts: 347
|
I would be really interested in seeing some pseudo or even real code for this.
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
First doubts for game developing | nandius_c | Coders. Asm / Hardware | 21 | 25 October 2013 12:21 |
Is there a Pacmania with sprite-collision disabled? | Predseda | request.Other | 3 | 30 January 2012 17:10 |
some doubts on the rom (kickstart) management in rommgr.cpp | pucci | support.WinUAE | 2 | 11 September 2011 14:42 |
what games need 'full' collision level ? | kirk | support.WinUAE | 25 | 07 February 2010 02:01 |
Slamtilt and RTC collision | Predseda | support.Games | 5 | 22 August 2009 22:28 |
|
|