Remaking of Alien Dropout in BlitzmaxNG

Started by Baggey, December 18, 2024, 17:39:36

Previous topic - Next topic

Baggey

Alien Dropout in BlitzmaxNG

Im trying to make my logo Bounce and slowly stop!? Anyone any ideas :-X

Oh you'll need this DropoutLOGO.png

' Alien Dropout inspired by REMID's bb conversion!
'
' Re-Written into .bmx By Baggey
'
' Hopefully someone can learn from this?

SuperStrict

AppTitle = " Alien Dropout"

Graphics 544,416

' Load Graphics
Rem
Global TitleScreen:TPixmap = LoadPixmap("graphics\main.png")
         If TitleScreen = Null Then
           RuntimeError ("Error Loading graphics\main.png")
         End If

Global mainScreen:TPixmap = LoadPixmap("graphics\screen.png")
         If mainScreen = Null Then
           RuntimeError ("Error Loading graphics\screen.png")
         End If

Global Font:TPixmap = LoadPixmap("graphics\font.png")
         If Font = Null Then
           RuntimeError ("Error Loading graphics\font.png")
         End If

Global FontINVERSE:TPixmap = LoadPixmap("graphics\FontINVERSE.png")
         If FontINVERSE = Null Then
           RuntimeError ("Error Loading graphics\FontINVERSE.png")
         End If
End Rem

Global dropoutLOGO:TPixmap = LoadPixmap("graphics\dropoutLOGO.png")
         If dropoutLOGO = Null Then
           RuntimeError ("Error Loading graphics\dropoutLOGO.png")
         End If

Global LogoX:Int=148, LogoY:Int, jump:Int=70

SetClsColor(0, 0, 0)
Cls

RunGame()

End

Function RunGame()

 Repeat

 Cls()

 If AppTerminate() Or KeyHit(Key_ESCAPE) Then End


 'DrawPixmap(TitleScreen,0,0)
 'DrawPixmap(mainScreen,0,0)
 'DrawPixmap(Font,16,0)
 'DrawPixmap(FontINVERSE,16,32)
 

 BounceLOGO()

 Flip(0)

 Forever

End Function


Function BounceLOGO()

 LogoY = jump * Sin(MilliSecs())

 DrawPixmap(dropoutLOGO, logoX, LogoY)

 'jump:-(0.25)
 
 
End Function

So i got it bouncing but im a little lost as to how i would slowly stop it?

edited SUVAT equations should do the trick!? Now how do i use those again? ::)

Kind Regards Baggey
Running a PC that just Aint fast enough!? i7 4Ghz Quad core 32GB ram  2x1TB SSD and NVIDIA Quadro K1200 on 2 x HP Z24's . DID Technology stop! Or have we been assimulated!

Windows10, Parrot OS, Raspberry Pi Black Edition! , ZX Spectrum 48k, C64, Enterprise 128K, The SID chip. Im Misunderstood!

Derron

To stop something you simply do what? decrease velocity!

How you decrease, it up to you:
- linear decrease -> speed = Max(0, speed - 1)
- non linear example -> speed = Max(0, speed * 0.5); If speed < 0.01 then speed = 0

There exists a ton of formulas for "interesting" movement patterns. Google will show them when looking for "easing equations" (or similar).
Here is my framework's variant of the most common ones:
https://github.com/TVTower/TVTower/blob/master/source/Dig/base.util.interpolation.bmx

in math.mod/vector.mod there is also an example which uses an equation to lower the energy of a ball to do the "bouncing"... might give you a hint too (I know, math.mod docs are not exposed on the website yet...)


bye
Ron

Baggey

Thanks @Derron for the velocity tip! . I realised i need to use float's as well ???
Running a PC that just Aint fast enough!? i7 4Ghz Quad core 32GB ram  2x1TB SSD and NVIDIA Quadro K1200 on 2 x HP Z24's . DID Technology stop! Or have we been assimulated!

Windows10, Parrot OS, Raspberry Pi Black Edition! , ZX Spectrum 48k, C64, Enterprise 128K, The SID chip. Im Misunderstood!

Midimaster

#3
Normaly "bouncing" is generated by subtracting gravity and loss of energy to a speed.

This can be simplified as you can see in this runnable example:

SuperStrict
Graphics 600,400
Global Gravity:Double=0.3
Global EnergyLoss:Double=0.9
Global y:Double=300
Global Speed:Double
Repeat
    Cls
    Speed = Speed-Gravity ' gravity works always downwards
    Y     = Y+speed
    If Y<0Then
        ' hitting the ground speed changes direction, but loses energie:
        Speed = -1.0 * Speed * EnergyLoss 
        Y=0
    EndIf
    DrawOval 300,300-y,40,40   
    Flip 1
Until AppTerminate()

You can play around with the parameters.
...back from North Pole.