Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

DragonRuby Game Toolkit

An intuitive 2D game engine. Fast, cross-platform, tiny, hot loaded. · By DragonRuby

Collision on Visual Sprite not Rectangle

A topic by BarrelDogGames created Jun 22, 2019 Views: 626 Replies: 5
Viewing posts 1 to 6

Hi,

I decided to have some fun with dragonruby by rewriting a game I'd started doing in godot.

I started off rather rocky- mostly due to not being that familiar with ruby , and only having the sample applications code as documentation (which is great until you want to do something that isn't covered in the samples, So I'm really looking forward to having some kind of official documentation :) )

My positive feedback is that I love how simple it is to just stuff done is- and how I just need a text editor.  No complicated IDE or tools required, no importing of assets etc

The brick wall I've hit at the moment is with collisions- I have a player sprite and a monster sprite  (both are png's with a transparent background) , I can get the collision working fine via:

if args.game.mob_sprite.intersects_rect? args.game.player_sprite

but that then causes the collision to happen when the invisible (transparent) parts of the sprites touch each other, I just want it to happen when the actual viable parts collide- otherwise the player would feel very cheated by not actually visibly touching the monster, yet colliding with it.

Hopefully I've explained that well... anyway is there a way to do this, I'm hoping its just me missing the obvious xD

Thanks

Developer(+1)

Arbitrary collision detection is in the works!

Awesome, Thanks for the update :)

In the meantime, you could try putting an offset on the rect. 

 if args.state.mob_sprite.intersects_rect? [args.state.player_sprite.x+20,args.state.player_sprite.y+10,args.state.player_sprite.w-40,args.state.player_sprite.h-20] 
Developer

There is also a `scale_rect` option (which is used in FlappyDragon to control difficulty).

Thanks Moby Pixel and Dev's , I ended up creating a couple of hit boxes on the monsters and using the scale_rect & rect_shift_* from the FlappyDragon sample in the end- as a temporary fix.

Still very much enjoying DragonRuby, it makes game developing fun again! :)