Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: Follow (Game Maker)  (Read 3430 times)

0 Members and 1 Guest are viewing this topic.
Follow (Game Maker)
« on: November 18, 2006, 07:57:37 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 413
Hello. I've only gotten back to using Game Maker after several years, and I'm having a bit of trouble. I have a shadow that is positioned below the character using the following code:
Code: [Select]
x = objCharacter.x+3;
y = objCharacter.y+11
It works fine, but when I have the character set to increase its y value by 0.25 using the following:
Code: [Select]
y += 0.25The shadow 'stutters'. I can sort of see the reason for this, but even if I use
Code: [Select]
x = round(objCharacter.x+3);
y = round(objCharacter.y+11)
It still stutters.
Now, I need the character to move at a speed of 0.25. Lowering the speed of the room is not an option. I've also already made it travel using an alarm that increases its x value by 1 every four frames, as opposed to 0.25 every frame.  I've also tried setting a 'ytarget' variable that increases by 0.25 every frame, then the character increases its y value when ytarget is more than 1 over the character's y value. Both methods work, but not efficiently and they're awkward. Also, I feel I should note that the character moves flawlessly, and that the shadow uses an image_alpha value of 0.5.
Is there anyway I could fix this?

Thanks,
Sir Cyrus.
Logged
Re: Follow (Game Maker)
« Reply #1 on: November 18, 2006, 10:21:26 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Female
  • Posts: 2374
Game Maker isn't really friendly with decimals. Try whole numbers instead.
Logged
Re: Follow (Game Maker)
« Reply #2 on: November 18, 2006, 10:25:48 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 2890
Moving an object by a decimal value in GameMaker causes severe tearing... I'm sorry, but it cannot be conquered :-\.
Logged

Koh

Re: Follow (Game Maker)
« Reply #3 on: November 18, 2006, 10:42:05 pm »
  • Tamer Koh
  • *
  • Reputation: +6/-0
  • Offline Offline
  • Gender: Male
  • Posts: 980
try using fractions
Logged
  • Megaclipse Games
Re: Follow (Game Maker)
« Reply #4 on: November 18, 2006, 11:58:29 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Female
  • Posts: 2374
If you're serious, then I recommend you don't have children.
Logged
Re: Follow (Game Maker)
« Reply #5 on: November 19, 2006, 03:39:26 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 413
Curses. I'll try to find a workaround, thanks for the replies.
Logged

Goodnight

Once and future Captain
Re: Follow (Game Maker)
« Reply #6 on: November 20, 2006, 09:10:40 pm »
  • With a Capital G
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 706
Well, yes, Game Maker is notoriously bad with demicals, so whenever you change a variable by 0.25, you might want to do some fractional rounding just to be sure.

Code: [Select]
y += 0.25
y = round(y*4)/4

One of my heart engines wasn't working properly until I added something like that for the life variable.

But I can tell you that isn't the problem. Whether the variables are properly rounded off or not, you're making one object's position equal to the others, so there can't be any difference between them.

If by 'stuttering' you mean the shadow always lags behind by 1 frame, that's probably because its Step event takes place before the character moves.

So you should either move this:
Code: [Select]
x = objCharacter.x+3;
y = objCharacter.y+11
to the Shadow's End Step event, or...
Change it to this:
Code: [Select]
objShadow.x = x+3;
objShadow.y = y+11
and have that in the Character's Step event.
Logged
Re: Follow (Game Maker)
« Reply #7 on: November 23, 2006, 02:29:03 am »
  • Taste the soup of my brain!
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 612
Well, yes, Game Maker is notoriously bad with demicals, so whenever you change a variable by 0.25, you might want to do some fractional rounding just to be sure.

Code: [Select]
y += 0.25
y = round(y*4)/4

One of my heart engines wasn't working properly until I added something like that for the life variable.

But I can tell you that isn't the problem. Whether the variables are properly rounded off or not, you're making one object's position equal to the others, so there can't be any difference between them.

If by 'stuttering' you mean the shadow always lags behind by 1 frame, that's probably because its Step event takes place before the character moves.

So you should either move this:
Code: [Select]
x = objCharacter.x+3;
y = objCharacter.y+11
to the Shadow's End Step event, or...
Change it to this:
Code: [Select]
objShadow.x = x+3;
objShadow.y = y+11
and have that in the Character's Step event.

GoodKnight, all that your first one will do is lock the player in their original position.
What I suggest you do is this:

Give the player another x and y variable, i/e real_x, real_y, or something else like that.
Then, at the end of every step event, add this:
Code: [Select]
objCharacter.x = floor(real_x);
objCharacter.y = floor(real_y);

This will allow the player to move, and will allow you to add 0.25 to the character's positions.
Logged
She'll pull out your feathers for her brand new hat and when she's done that she'll feed you to her cat.
People you love will turn their backs on you.  You'll lose your hair, your teeth. Your knife will fall of its sheath, but you still don't like to leave until the end of the movie.
If I threw my guitar out the window, so far down, would I start to regret it?  Or would I smile and watch it slowly fall?

Goodnight

Once and future Captain
Re: Follow (Game Maker)
« Reply #8 on: November 23, 2006, 06:56:08 am »
  • With a Capital G
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 706
GoodKnight, all that your first one will do is lock the player in their original position.

Code: [Select]
y = round(y*4)/4That code rounds y to the nearest quarter, so no, it doesn't lock the object in place.

You suggestion will also work, but like I said, that probably isn't the reason for the stutter.
Logged

Jed

Re: Follow (Game Maker)
« Reply #9 on: November 23, 2006, 08:42:29 am »
Maybe updating the postion in the draw event would remove ths stutter?
Logged
Re: Follow (Game Maker)
« Reply #10 on: November 23, 2006, 10:54:46 am »
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 4588
Try drawing?
Logged
the a o d c

Antidote

>.>
Re: Follow (Game Maker)
« Reply #11 on: November 24, 2006, 10:15:52 pm »
  • In all seriousness who's serious?
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1485
simple solution for a simple problem.
Two people so far have hit the nail on the head.
The simple solution i'm talking about is to completly remove the shadow object and draw the characters sprite and shadow in the draw event thusly:
Code: GML
  1. Step:
  2. {
  3.  shadow_x = x+3;
  4.  shadow_y = y+11;
  5. }
  6. Drawing:
  7. {
  8.  /* Simple Shadow drawing */
  9.  // Player
  10.  draw_sprite(sprite_index, image_index, x, y);
  11.  // Shadow
  12.  draw_sprite(sprShadow, 0, shadow_x, shadow_y);
  13. }
  14.  

Logged
  • Axiomatic Data Laboratories
Re: Follow (Game Maker)
« Reply #12 on: November 24, 2006, 10:18:01 pm »
  • Official Forum Hippie/Writer
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 200
simple solution for a simple problem.
Two people so far have hit the nail on the head.
The simple solution i'm talking about is to completly remove the shadow object and draw the characters sprite and shadow in the draw event thusly:
Code: GML
  1. Step:
  2. {
  3.  shadow_x = x+3;
  4.  shadow_y = y+11;
  5. }
  6. Drawing:
  7. {
  8.  /* Simple Shadow drawing */
  9.  // Player
  10.  draw_sprite(sprite_index, image_index, x, y);
  11.  // Shadow
  12.  draw_sprite(sprShadow, 0, shadow_x, shadow_y);
  13. }
  14.  



even easier would be to just forego the step event entirely and just put:
Code: [Select]
draw_sprite(sprShadow, 0, x+3, y+11);
in the draw event.  Saves lines, space, and does the same thing.
Logged

Antidote

>.>
Re: Follow (Game Maker)
« Reply #13 on: November 24, 2006, 10:20:16 pm »
  • In all seriousness who's serious?
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1485
i put the step event in there because if you want to reposition the shadow you can easily.
Logged
  • Axiomatic Data Laboratories
Re: Follow (Game Maker)
« Reply #14 on: November 26, 2006, 05:35:02 pm »
  • Am i here or am i not?...
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 238
and wy dont you have tha shaddow on te sprite?
Logged

Antidote

>.>
Re: Follow (Game Maker)
« Reply #15 on: November 26, 2006, 06:42:26 pm »
  • In all seriousness who's serious?
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1485
>_> for jumping and what not <_< seriously koll think about it.
Logged
  • Axiomatic Data Laboratories
Re: Follow (Game Maker)
« Reply #16 on: November 27, 2006, 08:23:27 pm »
  • Am i here or am i not?...
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 238
yeah but this should be so much easier..... ???
Logged

Jed

Re: Follow (Game Maker)
« Reply #17 on: November 28, 2006, 12:14:15 am »
He may wish to have it adjust its position from different light sources, or if I recall correctly, when link jumps the shadow stays in the same spot rather than disapears.
Logged
Re: Follow (Game Maker)
« Reply #18 on: November 28, 2006, 03:06:26 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 413
Thank you, everyone.
Goodnight's suggestion worked, I really appreciate the help.
Anyway, I wanted the shadow separate for jumping, and to save time from merging sprites.
Logged
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.089 seconds with 74 queries.

anything