Discuss Scratch

alexgoescrazy57
Scratcher
100+ posts

How to make costume changes progressively faster using variables.

Hi,

So in my game, I have the exact same costume system as I used in this game: https://scratch.mit.edu/projects/108644036/ What that does is it is a variable based costume system. In that costume system, I am trying to have it so that when the variable used in the game increases, the time in between costume transitions goes down, so it looks like he is moving faster. But, I can't figure out how to. Any ideas?

alexgoescrazy57
Check out some random games, don't know if you will like them, but here ya go: https://scratch.mit.edu/users/alexgoescrazy57/

when green flag clicked
forever
make something look kewl and complex
end
gtoal
Scratcher
1000+ posts

How to make costume changes progressively faster using variables.

There's no point in displaying costume changes faster than the screen refresh rate, so there will be an upper limit on how fast you can change costumes – let's say 30 times per second, So display frames at a constant rate (eg 30FPS) and adjust the apparent speed by changing the number of frames for which each costume is displayed. Ie a fast movement displays for 1 frame then changes, and half speed displays for 2 frames then changes, and so on.

You'll notice however that this gives speeds of 1/1, 1/2, 1/3, 1/4 etc of full speed - which is not a linear scale.

One way around this is to use fractional display times. But since you can't actually display for 1.5 frames, what you have to do is make one switch after 1 frame and the next switch after 2 frames, and continue to alternate between 1 and 2 to get the effect of changing at a rate of 1.5.

(This is similar to drawing diagonal lines with pixels - there are no half pixels - and the maths for deciding how many whole frames to display is the same as deciding how many whole pixels to plot at a given height on the y axis, with the x axis corresponding to time)

Graham

Last edited by gtoal (May 25, 2017 18:07:57)

footsocktoe
Scratcher
1000+ posts

How to make costume changes progressively faster using variables.

alexgoescrazy57 wrote:

Hi,

So in my game, I have the exact same costume system as I used in this game: https://scratch.mit.edu/projects/108644036/ What that does is it is a variable based costume system. In that costume system, I am trying to have it so that when the variable used in the game increases, the time in between costume transitions goes down, so it looks like he is moving faster. But, I can't figure out how to. Any ideas?

repeat until <>
set [control v] to [Here would be the function that decreases when the game variable increases. It might be as simple as 1 / game variable]
next costume
wait (control) secs
end



SHOOT THE SPACE MONSTERS! ….. A game everyone can play! Bright colors, bonky sounds!
THE 12 BALLS OF CRAZY AL ……. New scrolling adventure game!

alexgoescrazy57
Scratcher
100+ posts

How to make costume changes progressively faster using variables.

footsocktoe wrote:

alexgoescrazy57 wrote:

Hi,

So in my game, I have the exact same costume system as I used in this game: https://scratch.mit.edu/projects/108644036/ What that does is it is a variable based costume system. In that costume system, I am trying to have it so that when the variable used in the game increases, the time in between costume transitions goes down, so it looks like he is moving faster. But, I can't figure out how to. Any ideas?

repeat until <>
set [control v] to [Here would be the function that decreases when the game variable increases. It might be as simple as 1 / game variable]
next costume
wait (control) secs
end

Thank you!

alexgoescrazy57
Check out some random games, don't know if you will like them, but here ya go: https://scratch.mit.edu/users/alexgoescrazy57/

when green flag clicked
forever
make something look kewl and complex
end
ooftroydan
Scratcher
3 posts

How to make costume changes progressively faster using variables.

turn cw () degrees
ooftroydan
Scratcher
3 posts

How to make costume changes progressively faster using variables.

rest for () beats
when this sprite clicked<key [ yeet] pressed?>
ooftroydan
Scratcher
3 posts

How to make costume changes progressively faster using variables.

mmmmmmm wrote:

rest for () beats
when this sprite clicked<key [ yeet] pressed?>
wee
deck26
Scratcher
1000+ posts

How to make costume changes progressively faster using variables.

ooftroydan wrote:

mmmmmmm wrote:

rest for () beats
when this sprite clicked<key [ yeet] pressed?>
wee
Please don't spam or necropost. Both are reportable.

Powered by DjangoBB