Windows object shadow and collision shape changing - help needed

L

LeonelSaberTooth

Guest
hello, i am new to programming with game maker, and programming in general. currently im working on a small project that doesnt really have nothing in it but ive come to 2 problems.
1 - i want the player object i made to have 2 collision shapes changing whenever he switches his pose, the player sprite is a tiger, and when walking up or down it has a narrow sprite and when moving right or left a wide one, (see pictures below), i cant find a way to change it collision shape based on which sprite the object is currently using.

2 - since the object has a shadow (i made the shadow just a sprite and used the draw event to draw it, see pictures below), and the object is long or narrow based on its pose, the shadow needs to change to make sense, i did manage to makek the shadow sprite change if the player is moving on the x axis or y axis, but when the player stops moving the shadow disapears, so i need a way to make the shadow to stay as what it previously was when the player stops walking.
thank you very much for reading and helping :)

pic 1: player wide sprite, pic 2: player narrow sprite, pic 3: player shadow stops drawing when not moving, pic 4: shadow drawing code.



 
A

Ash Ketchum

Guest
Hey.
Im not great at code but...

If you have separate sprites for the collision masks.
You can write
Code:
If sprite_index = tigerleft_spr or tigerrite_spr
{
Mask_index = long
}
Else
Mask_index = thin
And maybe just have separate shadow sprites and change them accordingly.
 
L

LeonelSaberTooth

Guest
Hey.
Im not great at code but...

If you have separate sprites for the collision masks.
You can write
Code:
If sprite_index = tigerleft_spr or tigerrite_spr
{
Mask_index = long
}
Else
Mask_index = thin
And maybe just have separate shadow sprites and change them accordingly.
thanks! but how do i setup a mask index?
and for the second answer, there are two sprites for shadows, i can make it work but only activate one of them when not moving, when i want it to use the one that was previously used.
 
A

Ash Ketchum

Guest
Hey.
mask_index just sets the calling instance's mask to the sprite you = it to.

create event:
Code:
Hshadow = "the name of your long shadow"
Vshadow = "the name of your short shadow"
Step event:
Code:
if sprite_index = "name of your left sprite" or "name of your right sprite"
{
mask_index = "name of your horizontal  mask"
}
else
{
mask_index = "name of your vertical mask"
}

Draw event:
Code:
draw_sprite(sprite_index,1,x,y)

if sprite_index = "name of your left sprite"
{
draw_sprite(Hshadow,1,x,y)
}
else
{
draw_sprite(Vshadow,1,x,y)
}
This is basic stuff that is in the manual. You should really look minor stuff like this up in there before
posting here.
Its probably why you got no responses.
 
L

LeonelSaberTooth

Guest
Hey.
mask_index just sets the calling instance's mask to the sprite you = it to.

create event:
Code:
Hshadow = "the name of your long shadow"
Vshadow = "the name of your short shadow"
Step event:
Code:
if sprite_index = "name of your left sprite" or "name of your right sprite"
{
mask_index = "name of your horizontal  mask"
}
else
{
mask_index = "name of your vertical mask"
}

Draw event:
Code:
draw_sprite(sprite_index,1,x,y)

if sprite_index = "name of your left sprite"
{
draw_sprite(Hshadow,1,x,y)
}
else
{
draw_sprite(Vshadow,1,x,y)
}
This is basic stuff that is in the manual. You should really look minor stuff like this up in there before
posting here.
Its probably why you got no responses.

thank you very much again! as i said im really new to gamemaker, i dont know what the manual is... i understood the solution for the shadow problem, but still didnt understand the thing with the mask index, i can only make 1 collision shape for an object as far as i know, how do i create more?
thank you very much :)
 
A

Ash Ketchum

Guest
All you do is draw two separate sprites of the shape you want for collisions.
So two black rectangles. One short (for up and down) one long (for left and rite) these sprites will act as your masks. See?

So In the Step event at "name of horizontal mask" put the name of the long sprite.
 
L

LeonelSaberTooth

Guest
All you do is draw two separate sprites of the shape you want for collisions.
So two black rectangles. One short (for up and down) one long (for left and rite) these sprites will act as your masks. See?

So In the Step event at "name of horizontal mask" put the name of the long sprite.
thanks, but i still dont understand...
how can i turn a sprite into a collision shape?
i understand that im probably being annoying so u dont have to answer...
 
A

Ash Ketchum

Guest
Haha.
When you create an object and assign it a sprite, gamemaker automatically uses that sprite as it's collision mask. But you can change the mask to any other sprite you want with mask_index or in the objects window.
 
L

LeonelSaberTooth

Guest
Haha.
When you create an object and assign it a sprite, gamemaker automatically uses that sprite as it's collision mask. But you can change the mask to any other sprite you want with mask_index or in the objects window.
in my case, gamemaker justs automatically makes a collision shape, i cant see where to choose to make the sprite mask the collision shape, i see the "mask" section, but it doesnt do anything...
 
A

Ash Ketchum

Guest
How do you know the "mask" section doesn't do anything? have you tested it?
The objects sprite is the collision shape unless programmed otherwise.

Put a "create event" in your object events, then put a script in your create events actions, Then type....
Code:
mask_index = "name of your sprite"
The above will change your objects collision mask(sprite mask ,collision shape) to what ever sprite you put after =
where i put "name of your sprite" is where you put the name of your sprite.
That's the code way of doing it.

in that "mask" drop down, is another way of doing it (you just pick the sprite from the drop down)
 
L

LeonelSaberTooth

Guest
How do you know the "mask" section doesn't do anything? have you tested it?
The objects sprite is the collision shape unless programmed otherwise.

Put a "create event" in your object events, then put a script in your create events actions, Then type....
Code:
mask_index = "name of your sprite"
The above will change your objects collision mask(sprite mask ,collision shape) to what ever sprite you put after =
where i put "name of your sprite" is where you put the name of your sprite.
That's the code way of doing it.

in that "mask" drop down, is another way of doing it (you just pick the sprite from the drop down)
thank you very much!
 
Top