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!
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: http://gameml.iowoi.org/GameML-File-Sharing-h3.htmPlease add only games.
Create A GAMEML BLOG!
Make a Blog on GameML:http://gamemlblogs.wetpaint.com
Keywords


Sprite drawing

View previous topic View next topic Go down

Sprite drawing

Post by CarnivorousA on 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

_________________
avatar
CarnivorousA
Moderator
Moderator

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

View user profile http://entertainmypeople.freeforums.org/index.php

Back to top Go down

Re: Sprite drawing

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

make all codes relative.

_________________
Creator of GameML, Thanks for Visiting!
avatar
3d
Admin
Admin

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

View user profile http://gameml.iowoi.org

Back to top Go down

Re: Sprite drawing

Post by Hepolite on 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.
avatar
Hepolite
GameML Noob
GameML Noob

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

View user profile

Back to top Go down

Re: Sprite drawing

Post by CarnivorousA on 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?

_________________
avatar
CarnivorousA
Moderator
Moderator

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

View user profile http://entertainmypeople.freeforums.org/index.php

Back to top Go down

Re: Sprite drawing

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

what if you editted the speed of the image.

_________________
Creator of GameML, Thanks for Visiting!
avatar
3d
Admin
Admin

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

View user profile http://gameml.iowoi.org

Back to top Go down

Re: Sprite drawing

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

Game Maker always does stuff like this to me.

_________________
avatar
CarnivorousA
Moderator
Moderator

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

View user profile http://entertainmypeople.freeforums.org/index.php

Back to top Go down

Re: Sprite drawing

Post by Vivi_IX on 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.
avatar
Vivi_IX
Tres GameML Ninja
Tres GameML Ninja

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

View user profile http://www.yoyogames.com/members/Vivi_IX

Back to top Go down

Re: Sprite drawing

Post by CarnivorousA on 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.

_________________
avatar
CarnivorousA
Moderator
Moderator

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

View user profile http://entertainmypeople.freeforums.org/index.php

Back to top Go down

Re: Sprite drawing

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

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