Short IF statement must be on a single line!
Posted: Wed May 17, 2023 12:44 am
Here I am getting an error:
Short IF statement must be on a single line!
File: GAIA-X-sphere.HWS (current line: 42)
What is long and what is short : )
; Partikelsystem für die rotierende Sphere
Local particles = {} ; Array für die Partikel
Local numParticles = 100 ; Anzahl der Partikel
Local particleSpeed = 5 ; Geschwindigkeit der Partikel
Local rotationSpeed = 1 ; Geschwindigkeit der Rotation
Local particleTimer = 0 ; Timer für die Auslösung der Sonnenstürme
Local particleInterval = 5000 ; Intervall zwischen den Sonnenstürmen in Millisekunden
Local particleDuration = 1000 ; Dauer eines Sonnensturms in Millisekunden
; Funktion zum Initialisieren des Partikelsystems
Function InitParticles()
For I = 1 To numParticles
; Zufällige Startposition innerhalb der Sphere
Local angle = Rand(0, 360)
Local radius = Rand(50, 100)
Local startX = radius * Cos(angle)
Local startY = radius * Sin(angle)
; Zufällige Startgeschwindigkeit
Local speedX = Rand(-particleSpeed, particleSpeed)
Local speedY = Rand(-particleSpeed, particleSpeed)
; Partikel hinzufügen
particles = {x = startX, y = startY, dx = speedX, dy = speedY}
Next
EndFunction
; Funktion zum Aktualisieren der Partikelpositionen
Function UpdateParticles()
For I = 1 To numParticles
; Aktuelle Position und Geschwindigkeit des Partikels
Local posX = particles.x
Local posY = particles.y
Local speedX = particles.dx
Local speedY = particles.dy
; Neue Position berechnen
Local newX = posX + speedX
Local newY = posY + speedY
; Randprüfung und Umkehrung der Geschwindigkeit
If Abs(newX) > 100 Then
speedX = -speedX
EndIf
If Abs(newY) > 100 Then
speedY = -speedY
EndIf
; Neue Position und Geschwindigkeit setzen
particles.x = newX
particles.y = newY
particles.dx = speedX
particles.dy = speedY
Next
EndFunction
; Funktion zum Zeichnen der Partikel
Function DrawParticles()
For I = 1 To numParticles
; Aktuelle Position des Partikels
Local posX = particles.x
Local posY = particles[I].y
; Partikel zeichnen
Plot(posX, posY, orange)
Next
EndFunction
; Funktion zum Zeichnen der rotierenden Sphere
Function DrawSphere()
Local radius = 100 ; Radius der Sphere
Local centerX = 320 ; X-Koordinate des Zentrums
Local centerY = 240 ; Y-Koordinate des Zentrums
For angle = 0 To 360 Step 10
Local posX = centerX + radius * Cos(angle)
Local posY = centerY + radius * Sin(angle)
Plot(posX, posY, rot)
Next
EndFunction
; Funktion zum Zeichnen der Sonnenstürme
Function DrawSolarFlares()
For Each particle In particles
Local posX = particle.x
Local posY = particle.y
Local speedX = particle.dx
Local speedY = particle.dy
; Sonnenstürme auslösen
If particleTimer <= 0 Then
; Zufällige Richtung und Geschwindigkeit für den Sonnensturm
Local flareAngle = Rand(0, 360)
Local flareSpeed = Rand(2, 5)
Local flareDuration = Rand(500, 2000)
; Neue Geschwindigkeit für das Partikel setzen
particle.dx = speedX + flareSpeed * Cos(flareAngle)
particle.dy = speedY + flareSpeed * Sin(flareAngle)
; Timer und Dauer für den Sonnensturm setzen
particleTimer = particleInterval
particleDuration = flareDuration
EndIf
; Sonnensturm zeichnen
If particleTimer > 0 And particleTimer <= particleDuration Then
Plot(posX, posY, gelb)
EndIf
Next
EndFunction
; Partikelsystem initialisieren
InitParticles()
Repeat
; Hintergrund zeichnen
Background(schwarz)
; Sphere zeichnen
DrawSphere()
; Partikel aktualisieren
UpdateParticles()
; Sonnenstürme zeichnen
DrawSolarFlares()
; Partikel zeichnen
DrawParticles()
; Bild anzeigen
ShowDisplay()
; Kurze Pause
Delay(50)
; Timer für Sonnenstürme aktualisieren
particleTimer = particleTimer - 50
; Ereignisse abfangen
Until KeyHit(Key_Escape)
Short IF statement must be on a single line!
File: GAIA-X-sphere.HWS (current line: 42)
What is long and what is short : )
; Partikelsystem für die rotierende Sphere
Local particles = {} ; Array für die Partikel
Local numParticles = 100 ; Anzahl der Partikel
Local particleSpeed = 5 ; Geschwindigkeit der Partikel
Local rotationSpeed = 1 ; Geschwindigkeit der Rotation
Local particleTimer = 0 ; Timer für die Auslösung der Sonnenstürme
Local particleInterval = 5000 ; Intervall zwischen den Sonnenstürmen in Millisekunden
Local particleDuration = 1000 ; Dauer eines Sonnensturms in Millisekunden
; Funktion zum Initialisieren des Partikelsystems
Function InitParticles()
For I = 1 To numParticles
; Zufällige Startposition innerhalb der Sphere
Local angle = Rand(0, 360)
Local radius = Rand(50, 100)
Local startX = radius * Cos(angle)
Local startY = radius * Sin(angle)
; Zufällige Startgeschwindigkeit
Local speedX = Rand(-particleSpeed, particleSpeed)
Local speedY = Rand(-particleSpeed, particleSpeed)
; Partikel hinzufügen
particles = {x = startX, y = startY, dx = speedX, dy = speedY}
Next
EndFunction
; Funktion zum Aktualisieren der Partikelpositionen
Function UpdateParticles()
For I = 1 To numParticles
; Aktuelle Position und Geschwindigkeit des Partikels
Local posX = particles.x
Local posY = particles.y
Local speedX = particles.dx
Local speedY = particles.dy
; Neue Position berechnen
Local newX = posX + speedX
Local newY = posY + speedY
; Randprüfung und Umkehrung der Geschwindigkeit
If Abs(newX) > 100 Then
speedX = -speedX
EndIf
If Abs(newY) > 100 Then
speedY = -speedY
EndIf
; Neue Position und Geschwindigkeit setzen
particles.x = newX
particles.y = newY
particles.dx = speedX
particles.dy = speedY
Next
EndFunction
; Funktion zum Zeichnen der Partikel
Function DrawParticles()
For I = 1 To numParticles
; Aktuelle Position des Partikels
Local posX = particles.x
Local posY = particles[I].y
; Partikel zeichnen
Plot(posX, posY, orange)
Next
EndFunction
; Funktion zum Zeichnen der rotierenden Sphere
Function DrawSphere()
Local radius = 100 ; Radius der Sphere
Local centerX = 320 ; X-Koordinate des Zentrums
Local centerY = 240 ; Y-Koordinate des Zentrums
For angle = 0 To 360 Step 10
Local posX = centerX + radius * Cos(angle)
Local posY = centerY + radius * Sin(angle)
Plot(posX, posY, rot)
Next
EndFunction
; Funktion zum Zeichnen der Sonnenstürme
Function DrawSolarFlares()
For Each particle In particles
Local posX = particle.x
Local posY = particle.y
Local speedX = particle.dx
Local speedY = particle.dy
; Sonnenstürme auslösen
If particleTimer <= 0 Then
; Zufällige Richtung und Geschwindigkeit für den Sonnensturm
Local flareAngle = Rand(0, 360)
Local flareSpeed = Rand(2, 5)
Local flareDuration = Rand(500, 2000)
; Neue Geschwindigkeit für das Partikel setzen
particle.dx = speedX + flareSpeed * Cos(flareAngle)
particle.dy = speedY + flareSpeed * Sin(flareAngle)
; Timer und Dauer für den Sonnensturm setzen
particleTimer = particleInterval
particleDuration = flareDuration
EndIf
; Sonnensturm zeichnen
If particleTimer > 0 And particleTimer <= particleDuration Then
Plot(posX, posY, gelb)
EndIf
Next
EndFunction
; Partikelsystem initialisieren
InitParticles()
Repeat
; Hintergrund zeichnen
Background(schwarz)
; Sphere zeichnen
DrawSphere()
; Partikel aktualisieren
UpdateParticles()
; Sonnenstürme zeichnen
DrawSolarFlares()
; Partikel zeichnen
DrawParticles()
; Bild anzeigen
ShowDisplay()
; Kurze Pause
Delay(50)
; Timer für Sonnenstürme aktualisieren
particleTimer = particleTimer - 50
; Ereignisse abfangen
Until KeyHit(Key_Escape)