Collision - Help - Game Design - Forums
Tuesday, 2009-11-24, 11:20 Am
MainRegistrationLogin Welcome Guest | RSS

[New messages · Members · Forum rules · Search · RSS ]
Page 1 of 212»
Forum moderator: RomsMaster 
Forums » Game Design » Help » Collision (helpz)
Collision
RomsMasterDate: Sunday, 2008-12-07, 8:15 Am | Message # 1
Oderint Dum Metuant
Group: Moderators
Messages: 562
Reputation: 10
Status: Offline
Since their is no GM help section I guess I'll post this here. I'm making a quick stick man fighting game and I was wondering if anyone knew how to make collision rectangles.

I got the code but I don't know how it works:

Code
collision_rectangle(x1,y1,x2,y2,obj,prec,notme

I need this code to make the enemy get hurt when it gets attacked by a punch

Or

Does anyone now how to make it so the enemy gets hurt when I do an attack?

Any help would be appreciated.



 
RomsMasterDate: Sunday, 2008-12-07, 10:57 Pm | Message # 2
Oderint Dum Metuant
Group: Moderators
Messages: 562
Reputation: 10
Status: Offline
BUMP


 
ZaeDate: Sunday, 2008-12-07, 11:39 Pm | Message # 3
~Bladed Glory~ & king of Nightmares!
Group: Moderators
Messages: 138
Reputation: 1
Status: Offline
go ask in GMC, the pople there might be able to help

All hail the bunnies!
 
mavrikgamesDate: Sunday, 2008-12-07, 11:48 Pm | Message # 4
Admin
Group: Administrators
Messages: 517
Reputation: 3
Status: Offline
[MOVED]

And well I usualy use "hitboxes" which is just a invisble object with the sprite as a square/rectangle. And whenever the player attacks I just create a hitbox. This way is much quicker since it uses less objects and sprites though you could do it my way.....

Sadly I'm not surhow to do it. (will edit if I can figure out though...)





 
RomsMasterDate: Sunday, 2008-12-07, 11:55 Pm | Message # 5
Oderint Dum Metuant
Group: Moderators
Messages: 562
Reputation: 10
Status: Offline
Quote (mavrikgames)
And well I usualy use "hitboxes" which is just a invisble object with the sprite as a square/rectangle. And whenever the player attacks I just create a hitbox.

I wanted to do this but I don't know how. Ohw does this work?



 
mavrikgamesDate: Monday, 2008-12-08, 1:34 Am | Message # 6
Admin
Group: Administrators
Messages: 517
Reputation: 3
Status: Offline
Quote
I wanted to do this but I don't know how. Ohw does this work?

Of course it works, alot or maybe MOST people use this for fighting games. If you need to know how to do it, it's pretty simple;

just make a new sprite: square shape (just fill in the sprite box - make sure it's the proper size.... whatever it may be - I still have a;ot of problem with picking a good size) and make a object with the new sprite and make it invisble. And when the player punches with your character and whatnot just create the object and make sure the object get's destroyed on contact if it connects with a enemy or whatever. It's really simple actually.





 
RomsMasterDate: Monday, 2008-12-08, 4:40 Am | Message # 7
Oderint Dum Metuant
Group: Moderators
Messages: 562
Reputation: 10
Status: Offline
could you make an example? i don't quiet get it.

Wait NVM, I forgot your GM doesn't work.

Quote (mavrikgames)
make sure the object get's destroyed on contact if it connects with a enemy

wait, so if you punch and it misses, the 'hitbox' wont get destroyed because it didn't connect with the enemy.


 
mavrikgamesDate: Monday, 2008-12-08, 11:23 Pm | Message # 8
Admin
Group: Administrators
Messages: 517
Reputation: 3
Status: Offline
Quote (RomsMaster)

wait, so if you punch and it misses, the 'hitbox' wont get destroyed because it didn't connect with the enemy.

Well to remedy this, just destroy the object in it's animation end. Simple. smile




 
RomsMasterDate: Tuesday, 2008-12-09, 5:37 Am | Message # 9
Oderint Dum Metuant
Group: Moderators
Messages: 562
Reputation: 10
Status: Offline
I sorta get it but its too confusing. What do I use to destroy it? instance_destroy()?


 
mavrikgamesDate: Tuesday, 2008-12-09, 11:43 Pm | Message # 10
Admin
Group: Administrators
Messages: 517
Reputation: 3
Status: Offline
Quote (RomsMaster)
I sorta get it but its too confusing. What do I use to destroy it? instance_destroy()?

Yup. If you still need a example I can send you the small dbz game I'm working on.




 
DiamondDudeDate: Wednesday, 2008-12-10, 3:08 Am | Message # 11
Dustball
Group: Administrators
Messages: 12
Reputation: 0
Status: Offline
x1 is left
x2 is distance from x1 to x2
y1 is top
y2 is distance from y1 to y2

prec & notme can be set to 0


~DD~ a leader of the DDNN-Team
 
RomsMasterDate: Wednesday, 2008-12-10, 3:28 Am | Message # 12
Oderint Dum Metuant
Group: Moderators
Messages: 562
Reputation: 10
Status: Offline
Quote (mavrikgames)
If you still need a example I can send you the small dbz game I'm working on.

sure, i'm really confused on this.



 
mavrikgamesDate: Thursday, 2008-12-11, 1:11 Am | Message # 13
Admin
Group: Administrators
Messages: 517
Reputation: 3
Status: Offline
well your in for a wait cuz my computer's gonna be getting restore in the next few days. sad




 
RomsMasterDate: Thursday, 2008-12-11, 4:18 Am | Message # 14
Oderint Dum Metuant
Group: Moderators
Messages: 562
Reputation: 10
Status: Offline
D: can't wait dat long


 
billyroDate: Friday, 2008-12-12, 2:40 Am | Message # 15
Game Maker
Group: Moderators
Messages: 248
Reputation: 8
Status: Offline
I can help biggrin

Ok, when you are attacking, get the attack image_index where they do the actual attack (the image where you would do damage). You need an attacking object as well, eg. obj_attack. the obj_attack must have a variable called creator or something so it knows who created it and dosen't hit the player who made the attack.

Code
var atk; //this is creating a variable for attacking
atk=instance_create(x,y,obj_attack) //for creating the actual attack
atk.creator=id //this means that the attack won't hurt yourself
atk.sprite_index=sprite_index //this makes the attack your sprite
atk.image_index=image_index //this makes the attack at the image where you attack.

Also, this next part is for using image_xscale, if you use a sprite for right and left then leave out.
Code
//remember to join on up there ^
atk.image_xscale=image_xscale //which makes it face your direction

now with the obj_attack object, make a collision with the object that will take the hit and put

Code
if creator!=other.id //if the other person is not the creator
{
//Code hurt stuff here.
}

Now if there is anything else i can do then ask me. happy
also if it still doesn't make much sense then i made an example. Hitboxes example






Message edited by billyro - Friday, 2008-12-12, 2:52 Am
 
Forums » Game Design » Help » Collision (helpz)
Page 1 of 212»
Search:

Copyright MyCorp © 2009
Site managed by uCoz system