[23 Nov 2009] Sprite

Contains all messages from the Hollywood mailing list between 01/2006 and 08/2012
Locked
ArtBlink
Posts: 484
Joined: Mon Nov 01, 2010 10:37 am
Location: Albert - France
Contact:

[23 Nov 2009] Sprite

Post by ArtBlink »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Mon, 23 Nov 2009 15:54:33 -0000

Hello

I'm trying to make a minigame with scroll. The scrolling is good but i have problem with sprite. So, my sprite evoluting in 640x480 screen (for the moment, it's just a test) the x move is by 4 pixel but the animation of sprite is too fast, so, to slowing the animation, i use WRAP command (i add x variabl with 0.125) but sprite is accroching sometimes. Have you got an explication? i don't compile the program for the moment.

Thanks

Respect

User avatar
Allanon
Posts: 637
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

[24 Nov 2009] Re: Sprite

Post by Allanon »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Tue, 24 Nov 2009 08:33:16 -0000

Hello, I'm experimenting something similar these days, at the moment I've no scrolling in background but only one sprite that the player will move.

Actually I poll the user input with an interval function and each time this function gets the left or right buttons assigned to the movement the sprite position is updated adding or subtracting the <speed> variable.

In this way you can adjust the player speed with two parameters:

- the <speed> variable (the pixels to add or subtract from the current position)
- the interval function frequency

Hope this helps

Regards, Fabio
----------------------------
[Allanon] Fabio Falcucci
AMC - Creative Development // Docs Site // Support Forum
Support me on Patreon for Hollywood libraries!

ArtBlink
Posts: 484
Joined: Mon Nov 01, 2010 10:37 am
Location: Albert - France
Contact:

[24 Nov 2009] Re : Re: Sprite

Post by ArtBlink »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Tue, 24 Nov 2009 16:19:00 +0000 (GMT)

Hello

I think it's no that, wrap command allocate (if i understand this) the minimal value of floating number. so my variable is incremented by 0.125 value

If my var = 1.125 then my var=1 If my var = 1.25 then my var=1 etc..

I think i must delete command Wrap to write this at the place : (i have 5 image in sprite animation, myvar is image animation)

myvar=myvar+0.125 If1=<myvar<2 then myvar=1 If2=<myvar<3 then myvar=2 If3=<myvar<4 then myvar=3 If4=<myvar<5 then myvar=4 If myvar>5 then myvar=1

4 lines, or if i use wrap, i have 1 line. If my sprite animation have 10 or 15 image in sprite.... argh! a lot of test

Have you got solution? i think, i must use the absolute value of floating number (ABS) ?

Respect

User avatar
Allanon
Posts: 637
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

[24 Nov 2009] Re : Re: Sprite

Post by Allanon »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Tue, 24 Nov 2009 20:31:30 -0000

I've misunderstood what you have asked... I was thinking about moving a sprite but you want to animate a sprite right?

Again, I think the best way to achieve what you want is using an interval function, look at this:

Code: Select all

Local frame = 1
Function AnimateSprite()
    frame = frame + 1
    DisplaySprite( id, x, y, frame)
    If frame > 5 Then frame = 1
EndFunction

SetInterval(1, AnimateSprite, 20)

Repeat
   WaitEvent
Forever
This code will automatically update your animation every 20 milliseconds, this means 1000/20 = 50 times per second.

Can this example helps for your problem?

Regards, Fabio

PS: I've not tested this code but should work... :)
----------------------------
[Allanon] Fabio Falcucci
AMC - Creative Development // Docs Site // Support Forum
Support me on Patreon for Hollywood libraries!

User avatar
Allanon
Posts: 637
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

[24 Nov 2009] Re : Re: Sprite

Post by Allanon »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Tue, 24 Nov 2009 20:41:05 -0000

...regarding the wrap command...

Syntax: wrap(value, minval, maxval)

should be equal to following code:

Code: Select all

If value < minval Then Return(value - minvalue + maxvalue)
If value > maxval then Return(value - maxvalue + minvalue)
suppose to have:

Code: Select all

newval = Wrap(value, 1, 10)

if value = 5
newval = 5

if value = 0
newval = 0 - 1 + 10 --> 9

if value = 11
newval = 11 - 10 + 1 --> 2
Regards, Fabio
----------------------------
[Allanon] Fabio Falcucci
AMC - Creative Development // Docs Site // Support Forum
Support me on Patreon for Hollywood libraries!

ArtBlink
Posts: 484
Joined: Mon Nov 01, 2010 10:37 am
Location: Albert - France
Contact:

[25 Nov 2009] Re : Re: Sprite

Post by ArtBlink »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Wed, 25 Nov 2009 08:13:41 +0000 (GMT)

Hello

Yeah! good

My problem, i don't use function... in my programming experience (basic locomotive) we don't use fonction.

Thanks a lot for good code... i make my prototype 2d engine

RESPECT

ArtBlink
Posts: 484
Joined: Mon Nov 01, 2010 10:37 am
Location: Albert - France
Contact:

[01 Dec 2009] Re : Re: Sprite

Post by ArtBlink »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Tue, 1 Dec 2009 19:14:29 +0000 (GMT)

Hello,

I have problem with the fonction interval() My prg is too slow. So i have returned to my first idea and use command abs to insert in variable the absolute value to make good animation of sprites... the result is impressive, it's fast and the animation are very good, it's good to know.

User avatar
Allanon
Posts: 637
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

[02 Dec 2009] Re : Re: Sprite

Post by Allanon »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Wed, 02 Dec 2009 08:43:22 -0000

Ok, but if you try to decrease the interval you will obtain fast animations with my method too:

Code: Select all

SetInterval(1, AnimateSprite, 5)
for example the above command will call the animation function 1000/5 = 200 times every second

Regards, Fabio
----------------------------
[Allanon] Fabio Falcucci
AMC - Creative Development // Docs Site // Support Forum
Support me on Patreon for Hollywood libraries!

ArtBlink
Posts: 484
Joined: Mon Nov 01, 2010 10:37 am
Location: Albert - France
Contact:

[02 Dec 2009] Re : Re: Sprite

Post by ArtBlink »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Wed, 2 Dec 2009 17:29:48 +0000 (GMT)

Hello,

I decrease interval, but with a lot of sprite the game is slowing, with ABS command, and add variable with 0.25, all sprite move and anim good. I think interval command eat more system ressources about ABS command, what do you think with this strange result, attention i have MicroAone.

Thanks

Locked