Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Smooothness
#4
I took a moment to just restructure this a bit, to get rid of that EVIL goto....  (Not that I personally have anything against GOTOs.  Big Grin )

Code: (Select All)
Option _Explicit
Screen _NewImage(1280, 720, 32)
Randomize Timer: _MouseHide
_Delay .25: _ScreenMove _Middle

Type particle: As Single x, y, Vx, Vy: End Type
Dim As Integer c, reset_values
Dim As particle p(200)

reset_values = -1
Do
Cls
For c = 0 To UBound(p)
If reset_values Then
p(c).x = _Width / 2
p(c).y = c * -5 - 140
p(c).Vx = 0
p(c).Vy = 3 + (Rnd - Rnd) / 4
End If
p(c).x = p(c).x + p(c).Vx
p(c).y = p(c).y + p(c).Vy
If p(c).y > 20 And p(c).y < 26 Then p(c).Vx = (Rnd - Rnd) / 1.75 ' only change em once
If p(c).y > 14 Then p(c).Vy = p(c).Vy + .06 ' a little gravity
PSet (p(c).x, p(c).y), _RGB32(255)
Next
_Limit 60
_Display
If p(200).y > _Height + 140 Then reset_values = -1 Else reset_values = 0
Loop Until _KeyDown(27)
System


This runs and moves pretty dang smooth on my PC for me. I was thinking of swapping it over to use _MEM instead of PSET (and maybe swapping it over to just use hardware images instead of software) to see how it'd affect performance, but it doesn't seem necessary. Maybe my PC is just quick enough to run into any bottleneck/issue that you're seeing?
Reply


Messages In This Thread
Smooothness - by NakedApe - 10-10-2024, 10:31 PM
RE: Smooothness - by bplus - 10-10-2024, 10:38 PM
RE: Smooothness - by NakedApe - 10-11-2024, 01:22 AM
RE: Smooothness - by SMcNeill - 10-11-2024, 01:54 AM
RE: Smooothness - by NakedApe - 10-11-2024, 05:26 AM
RE: Smooothness - by DSMan195276 - 10-11-2024, 05:29 AM
RE: Smooothness - by NakedApe - 10-13-2024, 03:57 PM
RE: Smooothness - by SMcNeill - 10-13-2024, 05:42 PM
RE: Smooothness - by bplus - 10-13-2024, 07:02 AM
RE: Smooothness - by NakedApe - 10-13-2024, 07:37 PM



Users browsing this thread: 2 Guest(s)