Hello, thanks for visiting GameML, if you are a Game Maker user, this is the site for you, please sign up, or login if you are already a member, or just browse the site! Welcome to GameML!

ATTENTION MEMBERS!!! USERS CAN NOW SIGN UP AGAIN!

Join the forum, it's quick and easy

Hello, thanks for visiting GameML, if you are a Game Maker user, this is the site for you, please sign up, or login if you are already a member, or just browse the site! Welcome to GameML!

ATTENTION MEMBERS!!! USERS CAN NOW SIGN UP AGAIN!
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Log in

I forgot my password

Search
 
 

Display results as :
 


Rechercher Advanced Search

Site Hits
Free hit counter
These stats started at 0 on July 7th 2009
GameML File Sharing
USERNAME: gamemladmin@gmail.com PASSWORD: gamemlsite Upload Here: https://gameml.forumotion.com/GameML-File-Sharing-h3.htmPlease add only games.
Create A GAMEML BLOG!
Make a Blog on GameML:http://gamemlblogs.wetpaint.com

Sprite drawing

4 posters

Go down

Sprite drawing Empty Sprite drawing

Post by CarnivorousA Wed Jul 15, 2009 2:42 am

I'm having a little problem with making an object draw sprites at its own position.
In the draw event I have this code.
Code:
//draw all the body parts
draw_sprite(spr_player_body,facing,x,y)
draw_sprite(spr_player_hand,facing,x,y)
draw_sprite(spr_player_gun,(point_direction(x,y,mouse_x,mouse_y))/360*22,x,y)
//draw the feet, if the player is walking draw the feet walking
if hspeed == 0
draw_sprite(spr_player_feetr,0,x,y)
if !hspeed == 0
{
if hspeed > 0
draw_sprite(spr_player_feetr,-1,x,y)
if !hspeed > 0
draw_sprite(spr_player_feetl,-1,x,y)
}
The variable facing is to tell which direction the object is facing in, it has been created, and changes when the left and right keys are pressed. spr_player_feetr and spr_player_feetl are sprites of the feet walking in different directions, so when hspeed is 0 it draws the feet not moving, and when hspeed is over 0 it draws feet walking right, and when its under 0 it draws them walking left. But it doesn't do that. It always draws the feet just not moving, and when the player jumps the feet disappear altogether. Can someone please fix this? Thank you for reading Smile
CarnivorousA
CarnivorousA
Moderator
Moderator

Posts : 1402
Points : 56492
GameML Reputation : 17
Join date : 2009-06-01
Age : 29
Location : At the bottom of the lake.

http://entertainmypeople.freeforums.org/index.php

Back to top Go down

Sprite drawing Empty Re: Sprite drawing

Post by 3d Wed Jul 15, 2009 6:07 am

make all codes relative.
3d
3d
Admin
Admin

Posts : 1227
Points : 66276
GameML Reputation : 66
Join date : 2009-05-31
Age : 41
Location : U.S.A

https://gameml.forumotion.com

Back to top Go down

Sprite drawing Empty Re: Sprite drawing

Post by Hepolite Wed Jul 15, 2009 7:40 am

Try this:
Code:

if hspeed == 0
draw_sprite(spr_player_feetr,0,x,y)
if hspeed != 0
{
if hspeed > 0
draw_sprite(spr_player_feetr,-1,x,y)
if hspeed < 0
draw_sprite(spr_player_feetl,-1,x,y)
}

What you did, was "if !hspeed == 0", and that makes little sense. It should either be "if !(hspeed == 0)" or "if (hspeed != 0)". The position of the ! and parathesis does matter. That's why I don't like the sloppy syntax of GML, it makes everything harder -_-

ALWAYS use parenthesis around an if-statement, no matter how short it is, and ALWAYS use brackets "{" after the if-statement. It will save you so much trouble later on.
Hepolite
Hepolite
GameML Noob
GameML Noob

Posts : 23
Points : 54587
GameML Reputation : 12
Join date : 2009-06-03
Age : 31
Location : Land far, far away from the land far, far awaay

Back to top Go down

Sprite drawing Empty Re: Sprite drawing

Post by CarnivorousA Wed Jul 15, 2009 6:14 pm

Thanks for the tip, but it's still not animated. That's solved the problem of the feet disappearing when the player's not on the ground, but the feet aren't walking. Is there anything else I can try?
CarnivorousA
CarnivorousA
Moderator
Moderator

Posts : 1402
Points : 56492
GameML Reputation : 17
Join date : 2009-06-01
Age : 29
Location : At the bottom of the lake.

http://entertainmypeople.freeforums.org/index.php

Back to top Go down

Sprite drawing Empty Re: Sprite drawing

Post by 3d Wed Jul 15, 2009 7:18 pm

what if you editted the speed of the image.
3d
3d
Admin
Admin

Posts : 1227
Points : 66276
GameML Reputation : 66
Join date : 2009-05-31
Age : 41
Location : U.S.A

https://gameml.forumotion.com

Back to top Go down

Sprite drawing Empty Re: Sprite drawing

Post by CarnivorousA Wed Jul 15, 2009 7:51 pm

Game Maker always does stuff like this to me.
CarnivorousA
CarnivorousA
Moderator
Moderator

Posts : 1402
Points : 56492
GameML Reputation : 17
Join date : 2009-06-01
Age : 29
Location : At the bottom of the lake.

http://entertainmypeople.freeforums.org/index.php

Back to top Go down

Sprite drawing Empty Re: Sprite drawing

Post by Vivi_IX Sat Jul 25, 2009 10:04 pm

Try this (it's basically the same thing Hepolite did):
Code:

if hspeed == 0
{draw_sprite(spr_player_feetr,0,x,y);}
else
{
if hspeed > 0
{draw_sprite(spr_player_feetr,-1,x,y)}
if hspeed < 0
{draw_sprite(spr_player_feetl,-1,x,y)}
}

Make sure you dont have any code that is interfering with the image_index of this object that may cause the feet to stop moving; such as image_speed = 0. And aslo make sure that these sprites are actually animated as you want them.
Vivi_IX
Vivi_IX
Tres GameML Ninja
Tres GameML Ninja

Posts : 164
Points : 54388
GameML Reputation : 14
Join date : 2009-07-09
Age : 34
Location : USA: Painesville, Ohio

http://www.yoyogames.com/members/Vivi_IX

Back to top Go down

Sprite drawing Empty Re: Sprite drawing

Post by CarnivorousA Sun Jul 26, 2009 9:20 pm

Thanks guys but it's... still not doing what I want it to do. I don't know why it's doing this to me, and things like this always happen.
CarnivorousA
CarnivorousA
Moderator
Moderator

Posts : 1402
Points : 56492
GameML Reputation : 17
Join date : 2009-06-01
Age : 29
Location : At the bottom of the lake.

http://entertainmypeople.freeforums.org/index.php

Back to top Go down

Sprite drawing Empty Re: Sprite drawing

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum