Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - Collision detection (was: A question about development)

Reply to topic
Author Message
Bofner
  • Guest
Reply with quote
Collision detection (was: A question about development)
Post Posted: Sat Jan 16, 2021 4:20 am
Hi all! I'm happy to see that there's a community based around game development for the SMS! That's pretty exciting.

I'm trying to learn the ropes, and while I've hit a lot of road blocks, I've managed to figure stuff out on my own up to this point just based off of Maxim and hang on's tutorials as well as the official documents, but since this is my first time really programming with an assembly language, it's a bit challenging.

My question right now is about collision. I'm making a really short project right now to get started, and it's based off of hang on's Racer game. Pretty much I have some ships, and I want to be able to attack those ships. Rather than just checking to see if ANY collision has happened, I'd like to know WHICH sprites are touching, in order to determine if the player has died, or if the player has killed an enemy.

What's the way to go about this aside from just checking to see if ANY two sprites are colliding? I'll attach my source code in case that helps.

Thanks!

tl;dr
How does collision work and can I tell which sprites are colliding?
Bofner_Game.zip (10.49 KB)

 
  • Joined: 14 Oct 2008
  • Posts: 373
Reply with quote
Post Posted: Sat Jan 16, 2021 6:57 am
There are MANY ways to check collision in games.

Though as I hear, it is most common to use "hitboxes".
That is, to regard collidable objects as squares/rectangles, since it's easier and faster to check X/Y coordinates of the hitboxes.

Usually more fairly-designed games would make the hitboxes smaller than the visible sprites. (since making the hitbox bigger than the sprite would mean that hits would register before they even physically touch)
(Like imagine whatever oddly shaped character you can. Then imagine drawing the biggest box you can on top of them which still remains entirely without crossing over any edges of the character.)
  View user's profile Send private message
  • Joined: 16 May 2002
  • Posts: 1211
  • Location: italy
Reply with quote
Post Posted: Sat Jan 16, 2021 7:58 am
This is largely unrelated since it's about the Amiga, but I think it's always good to listen when a legend like Jon Burton talks about something: http://youtube.com/watch?v=UtWZEqmO-aA.
  View user's profile Send private message Visit poster's website
  • Joined: 01 Feb 2014
  • Posts: 601
Reply with quote
Post Posted: Sat Jan 16, 2021 8:03 am
First, welcome to the forums. It's always good to see new developers coming on board.

I was in the same place as you when I started out in 2014. I knew literally nothing about coding in assembly and only had some vague ideas about the way the SMS hardware works. I persevered, though, and the SMSpower community has proven extremely nice and always helpful whenever I had some (often stupid) questions.

One advice I can give to anyone starting out is to read up on interrupts and learn how to set up a proper vblank interrupt. Maxim's example uses a counter to achieve the same effect and is simple enough for this to work, but you'll run into trouble soon once your project becomes a little bit more complex.

On the topic of collision, hang-on's game is a very special case and probably the only one where using the collision bit actually works. As KingMike says, hitboxes are the way to go. Basically, you keep track where two sprites are and check periodically if they are near enough to touch.

Jonathan Cauldwell's tutorial for Spectrum programmers has a whole chapter dedicated to collision that explains the basics pretty well. In fact, I can't recommend his document enough. It touches on many other interesting issues too. The download is linked from the 'getting started' page in the development section.
  View user's profile Send private message
Bofner
  • Guest
Reply with quote
Post Posted: Sun Jan 17, 2021 12:55 am
Kagesan wrote

Jonathan Cauldwell's tutorial for Spectrum programmers has a whole chapter dedicated to collision that explains the basics pretty well. In fact, I can't recommend his document enough. It touches on many other interesting issues too. The download is linked from the 'getting started' page in the development section.


Perfect! I'll take a look there and see what I can figure out! Thanks!
 
Reply to topic



Back to the top of this page

Back to SMS Power!