Feuerwerk

Übersicht BlitzBasic Codearchiv

Neue Antwort erstellen

Devils Child

Betreff: Feuerwerk

BeitragFr, Jun 10, 2005 17:08
Antworten mit Zitat
Benutzer-Profile anzeigen
hi!
hier mal ein kleines 2s-feuerwerk(habs in 5 min geproggt und habs jetzt als auktueeln screensaver Wink )
Code: [AUSKLAPPEN]
Graphics 800, 600, 32, 1
SetBuffer BackBuffer()

;Types
Type Bomb
  Field x#, y#, xs#, ys#, time#
End Type
Type Explosion
  Field x#, y#, xs#, ys#, col1#, col2#, col3#
End Type

While Not KeyHit(1)
  Cls

  LockBuffer()
  i = Rand(1, 10)
  If i = 5 Then AddBomb()

  UpdateExplosions()
  UpdateBombs()
  UnlockBuffer()

  Flip
Wend
End

Function AddBomb()
b.Bomb = New Bomb
b\x# = Rand(1, GraphicsWidth())
b\y# = GraphicsHeight()
b\xs# = Rand(-100, 100)
b\ys# = Rand(-250, -300)
End Function

Function UpdateBombs()
Color 255, 255, 255
For b.Bomb = Each Bomb
  b\time# = b\time# + 1
  Rectangle(b\x# - 2, b\y# - 2, 4, 4)
  b\x# = b\x# + b\xs# / 30
  b\y# = b\y# + b\ys# / 30
  b\ys# = b\ys# + 3
  If b\time# > 100 Then
    For i = 1 To 200

      AddExplosion(b\x#, b\y#)
    Next
    Delete b
  EndIf
Next
End Function

Function UpdateExplosions()
For e.Explosion = Each Explosion
  e\x# = e\x# + e\xs# / 100
  e\y# = e\y# + e\ys# / 100
  e\ys# = e\ys# + 10
  Color e\col1#, e\col2#, e\col3#
  Line e\x#, e\y#, e\x#, e\y#
  e\col1# = e\col1# - 1
  e\col2# = e\col2# - 1
  e\col3# = e\col3# - 1
  If e\col1# < 0 And e\col2# < 0 And e\col3# < 0 Then Delete e
Next
End Function

Function AddExplosion(posx#, posy#)
e.Explosion = New Explosion
e\x# = posx#
e\y# = posy#
e\xs# = Rand(-300, 300)
e\ys# = Rand(-300, 300)
e\col1# = Rand(100, 255)
e\col2# = Rand(100, 255)
e\col3# = Rand(100, 255)
End Function

Function Rectangle(x1, y1, x2, y2)
x2 = x2 + x1
y2 = y2 + y1
For i = 1 To x2 - x1 + 1
  Line x1 + i, y1, x2 + i - 4, y2
Next
End Function

dient vorallem für noobs als lernhilfe bei types Smile
*X-Ware Member*

Mission to Hell[Ego-Shooter]
Hier Vollversion runterladen:
http://patrick-sch.de/spiele/m...ersion.zip

ich antworte auf jede PN
 

gamble

BeitragFr, Jun 10, 2005 17:22
Antworten mit Zitat
Benutzer-Profile anzeigen
Ruckelt bei mir nach kurzer Zeit.

Devils Child

BeitragFr, Jun 10, 2005 17:23
Antworten mit Zitat
Benutzer-Profile anzeigen
dann ersetzt die funktion:
Code: [AUSKLAPPEN]
Function UpdateBombs()
Color 255, 255, 255
For b.Bomb = Each Bomb
  b\time# = b\time# + 1
  Rectangle(b\x# - 2, b\y# - 2, 4, 4)
  b\x# = b\x# + b\xs# / 30
  b\y# = b\y# + b\ys# / 30
  b\ys# = b\ys# + 3
  If b\time# > 100 Then
    For i = 1 To 200

      AddExplosion(b\x#, b\y#)
    Next
    Delete b
  EndIf
Next
End Function


durch folgende:
Code: [AUSKLAPPEN]
Function UpdateBombs()
Color 255, 255, 255
For b.Bomb = Each Bomb
  b\time# = b\time# + 1
  Rectangle(b\x# - 2, b\y# - 2, 4, 4)
  b\x# = b\x# + b\xs# / 30
  b\y# = b\y# + b\ys# / 30
  b\ys# = b\ys# + 3
  If b\time# > 100 Then
    For i = 1 To 150;<--  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

      AddExplosion(b\x#, b\y#)
    Next
    Delete b
  EndIf
Next
End Function
*X-Ware Member*

Mission to Hell[Ego-Shooter]
Hier Vollversion runterladen:
http://patrick-sch.de/spiele/m...ersion.zip

ich antworte auf jede PN

Spikespine

BeitragFr, Jun 10, 2005 17:40
Antworten mit Zitat
Benutzer-Profile anzeigen
hallo,

ich finde, es sieht unschön aus, dass die Partikel in einem Rechteck auseinanderfliegen.
Speedmäßig könntest du anstatt Line
ql:WritePixel oder
ql:WritePixelFast verwenden.


ansonsten ist es schön geworden Smile

Spike
Athlon 64 3700+ | 1024 MB RAM | GeForce 7900 GT | Blitz2D, Blitz3D, BlitzPlus, BlitzMax

Devils Child

BeitragFr, Jun 10, 2005 18:10
Antworten mit Zitat
Benutzer-Profile anzeigen
jetzt fetzt es aber so richtig!

Code: [AUSKLAPPEN]
Graphics 800, 600, 32, 1
SetBuffer BackBuffer()

;Types
Type Bomb
  Field x#, y#, xs#, ys#, time#
End Type
Type Explosion
  Field x#, y#, xs#, ys#, col#[3]
End Type

While Not KeyHit(1) Or MouseXSpeed() < -3 Or MouseYSpeed() < -3
  Cls

  LockBuffer()
  i = Rand(1, 10)
  If i = 5 Then AddBomb()

  UpdateExplosions()
  UpdateBombs()
  UnlockBuffer()

  Flip
Wend
End

Function AddBomb()
b.Bomb = New Bomb
b\x# = Rand(1, GraphicsWidth())
b\y# = GraphicsHeight()
b\xs# = Rand(-100, 100)
b\ys# = Rand(-250, -300)
End Function

Function UpdateBombs()
For b.Bomb = Each Bomb
  b\time# = b\time# + 1
  Rectangle(b\x# - 2, b\y# - 2, 4, 4)
  b\x# = b\x# + b\xs# / 30
  b\y# = b\y# + b\ys# / 30
  b\ys# = b\ys# + 3
  If b\time# > 100 Then
    For i = 1 To 500
      AddExplosion(b\x#, b\y#)
    Next
    Delete b
  EndIf
Next
End Function

Function UpdateExplosions()
For e.Explosion = Each Explosion
  e\x# = e\x# + e\xs# / 100
  e\y# = e\y# + e\ys# / 100
  e\ys# = e\ys# + 10
  Color e\col#[1], e\col#[2], e\col#[3]
  WritePixel e\x#, e\y#, e\col#[1] * $10000 + e\col#[2] * $100 + e\col#[3]
  For i = 1 To 3
    e\col#[i] = e\col#[i] - 2
    If e\col#[i] < 0 Then e\col#[i] = 0
  Next
  If e\col#[1] < 1 And e\col#[2] < 1 And e\col#[3] < 1 Or e\y# > GraphicsHeight() Then Delete e
Next
End Function

Function AddExplosion(x#, y#)
e.Explosion = New Explosion
e\x# = x#
e\y# = y#
e\xs# = Tan(Rand(-300, 300)) * 60
e\ys# = Tan(Rand(-300, 300)) * 60
For i = 1 To 3
  e\col#[i] = Rand(100, 255)
Next
End Function

Function Rectangle(x1, y1, x2, y2)
For x = 1 To x2
  For y = 1 To y2
    WritePixel x1 + x, y1 + y, 16777215
  Next
Next
End Function
*X-Ware Member*

Mission to Hell[Ego-Shooter]
Hier Vollversion runterladen:
http://patrick-sch.de/spiele/m...ersion.zip

ich antworte auf jede PN
 

Hallosager

BeitragSa, Jun 11, 2005 21:30
Antworten mit Zitat
Benutzer-Profile anzeigen
Und wie hast du es zu Bildschirmschoner gemacht?
 

FBI-blitz

BeitragSa, Jun 11, 2005 22:23
Antworten mit Zitat
Benutzer-Profile anzeigen
sieht doch sehr schön aus Very Happy
Computer 1: AMD Athlon64 3500+ | nVidia GF 7900GT | 1024 MB DDR-RAM | ASUS A8N-SLI Preimium | 250 GB SATA 2 || WindowsXP | Blitz3D | Blitz+
Computer 2: AMD AthlonXP 2400+ | ATI Radeon 9500 | 512 MB DDR-RAM | MSI K7N2 | 80 GB IDE | 160 GB IDE || WindowsXP | Blitz3D | Blitz+
Computer 3: Intel Pentium MMX | onBoard-Grafik | 32 MB RAM | 1 GB IDE || Windows 98 SE | Blitz+

Sir Dan

BeitragSo, Jun 12, 2005 5:58
Antworten mit Zitat
Benutzer-Profile anzeigen
@Hallosager

Schau dir mal das an : https://www.blitzforum.de/viewtopic.php?t=6627
(\_/)
(O.o)
(> <) This is Bunny. Copy Bunny into your signature to help him on his way to world domination.

Devils Child

BeitragSo, Jun 12, 2005 9:25
Antworten mit Zitat
Benutzer-Profile anzeigen
hm:
einfach:
1. endung von exe auf scr umbenennen, und dann ab in c:\windows\system32\
danach in den eigenschaften auswählen und fertig Wink
*X-Ware Member*

Mission to Hell[Ego-Shooter]
Hier Vollversion runterladen:
http://patrick-sch.de/spiele/m...ersion.zip

ich antworte auf jede PN

hectic

Sieger des IS Talentwettbewerb 2006

BeitragMo, Jul 11, 2005 5:09
Antworten mit Zitat
Benutzer-Profile anzeigen
Hallo Devils,
um die rechteckigen Explosionen zu vermeiden kann man sin und cos benutzen. Da diese Funktionen aber viel Rechengeschwindigkeit benötigen gibt es eine sehr gute alternative.

Nimm für die Explosionen

nicht
Rand(-300,300)

sondern
Rand(-150,150)+Rand(-150,150)

dann sieht es auch realistischer aus Wink

Spikespine

BeitragMo, Jul 11, 2005 14:08
Antworten mit Zitat
Benutzer-Profile anzeigen
@hectic: ist das nicht das gleiche?
Athlon 64 3700+ | 1024 MB RAM | GeForce 7900 GT | Blitz2D, Blitz3D, BlitzPlus, BlitzMax
 

Hallosager

BeitragMo, Jul 11, 2005 14:25
Antworten mit Zitat
Benutzer-Profile anzeigen
Warum kommt die E-mailbenachrichtigung von diesem Thread in meinen Spamverdachtordner?

Artemis

BeitragMo, Jul 11, 2005 17:38
Antworten mit Zitat
Benutzer-Profile anzeigen
Hallosager hat Folgendes geschrieben:
Warum kommt die E-mailbenachrichtigung von diesem Thread in meinen Spamverdachtordner?


1. Das hat überhaupt nix hier verloren
2. Frag das dein Postfach
3. Mods bitte seinen und meinen Post löschen/trashen

hectic

Sieger des IS Talentwettbewerb 2006

BeitragMo, Jul 11, 2005 20:05
Antworten mit Zitat
Benutzer-Profile anzeigen
@Spikespine,
probier aus und du wirst sehen das es nicht das gleiche ist. Dadurch das es eher unwahrschweinlich ist das beide X und BEIDE Y -Zufallswerte ihre maximalwere hintereinander abgeben, wird eine fast Runde form der Knaller abgefeuert. Lieber erst mal probieren.

Spikespine

BeitragMo, Jul 11, 2005 20:30
Antworten mit Zitat
Benutzer-Profile anzeigen
oh oh, sorry hectic, da war ich wohl zu voreilig...
Du hast natürlich recht! Embarassed
Athlon 64 3700+ | 1024 MB RAM | GeForce 7900 GT | Blitz2D, Blitz3D, BlitzPlus, BlitzMax

Devils Child

BeitragSa, Jul 16, 2005 21:03
Antworten mit Zitat
Benutzer-Profile anzeigen
gute idee, aber tan sieht fetziger aus.

Code: [AUSKLAPPEN]
Graphics 800, 600, 32, 1
SetBuffer BackBuffer()

;Types
Type Bomb
  Field x#, y#, xs#, ys#, time
End Type
Type Explosion
  Field x#, y#, xs#, ys#, col[3]
End Type

Const Width = 800
Const Height = 600

While Not KeyHit(1) Or MouseXSpeed() < -3 Or MouseYSpeed() < -3
  Cls
  LockBuffer()
  If Rand(1, 3) = 2 Then
    b.Bomb = New Bomb
    b\x = Rand(0, Width)
    b\y = Height
    b\xs = Rand(-100, 100)
    b\ys = Rand(-250, -300)
  EndIf

  ;Explosions
  cnt_expl = 0
  For e.Explosion = Each Explosion
    cnt_expl = cnt_expl + 1
    e\x = e\x + e\xs / 100
    e\y = e\y + e\ys / 100
    e\ys = e\ys + 10
    If Floor(e\x) > 0 And  Floor(e\x) < Width And Floor(e\y) > 0 And  Floor(e\y) < Height Then WritePixelFast Floor(e\x), Floor(e\y), e\col[1] * $10000 + e\col[2] * $100 + e\col[3]
    For i = 1 To 3
      e\col[i] = e\col[i] - 2
      If e\col[i] < 0 Then e\col[i] = 0
    Next
    If e\col[1] + e\col[2] + e\col[3] < 20 Or e\y > Height Or e\x < 0 Or e\x > Width Then Delete e
  Next

  ;Bombs
  cnt_bombs = 0
  For b.Bomb = Each Bomb
    cnt_bombs = cnt_bombs + 1
    b\time = b\time + 1
    For x = -2 To 2
      For y = -2 To 2
        If b\x + x > 0 And b\x + x < Width And b\y + y > 0 And b\y + y < Height Then WritePixelFast b\x + x, b\y + y, 16777215
      Next
    Next
    b\x = b\x + b\xs / 30
    b\y = b\y + b\ys / 30
    b\ys = b\ys + 3
    If b\x < 0 Or b\x > Width Then b\xs = -b\xs
    If b\time > 100 Then
      For i = 1 To 300
        e.Explosion = New Explosion
        e\x = b\x
        e\y = b\y
        e\xs = Tan(Rand(-10000, 10000)) * 60
        e\ys = Tan(Rand(-10000, 10000)) * 60
        For a = 1 To 3
          e\col[a] = Rand(100, 255)
        Next
      Next
      Delete b
    EndIf
  Next

  UnlockBuffer()
  Flip

  If rec_bombs < cnt_bombs Then rec_bombs = cnt_bombs
  If rec_expl < cnt_expl Then rec_expl = cnt_expl
  Locate 5, 5:  Print "Bombs     : " + cnt_bombs
  Locate 5, 15: Print "Particles : " + cnt_expl
  Locate 5, 25: Print "----------------------"
  Locate 5, 35: Print "Record Bombs     : " + rec_bombs
  Locate 5, 45: Print "Record Particles : " + rec_expl
Wend
End


und bitte den DEBUGGER AUSSCHALTEN!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ps: hab mal auf blitzbase das optimierungs tut von thesadow gelesen und mal rumoptimiert!
edit: dis is ein screensaver, also nicht die maus bewegen!
*X-Ware Member*

Mission to Hell[Ego-Shooter]
Hier Vollversion runterladen:
http://patrick-sch.de/spiele/m...ersion.zip

ich antworte auf jede PN

Neue Antwort erstellen


Übersicht BlitzBasic Codearchiv

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group