Kleine Partikel...

Übersicht BlitzBasic Codearchiv

Neue Antwort erstellen

ChrisAttack

Betreff: Kleine Partikel...

BeitragSa, Mai 08, 2004 17:36
Antworten mit Zitat
Benutzer-Profile anzeigen
Mir war langweilig, also fragt bitte nicht wozu es gut sein soll Laughing
Also... für einen einfachen internen effekt für eine art bullettime find ich es ganz gut...

BlitzBasic: [AUSKLAPPEN]

;Interne Partikelengine by ChrisAttack

;Bild erstellen
;Particle
Global particle_pic=CreateImage(50,50)
SetBuffer ImageBuffer(particle_pic)
Color 100,100,100
Oval 0,0,50,50,1
SaveImage particle_pic,"particle_pic.JPG"
;Leader
Global leader_pic=CreateImage(50,50)
SetBuffer ImageBuffer(leader_pic)
Color 0,0,255
Oval 0,0,50,50,1
SaveImage leader_pic,"leader_pic.JPG"


;Type "particle"
Type particle
Field sprite
Field health
End Type

;Mousecolors
Dim UDFColor(2)
UDFColor(1) = $000000
UDFColor(2) = $FFFFFF

Graphics3D 1024,768,32,1
SetBuffer BackBuffer()

;Cam
cam = CreateCamera()
PositionEntity cam,0,0,-30

;Sprite
Global sprite = LoadSprite("particle_pic.JPG")
HideEntity sprite
Global leader = LoadSprite("leader_pic.JPG")

;Global Variables
Global timer
Global KK = CreatePivot()
EntityParent leader,KK
Global Winkel
;FPS
Global fps_anzeige
Global fps_ms=MilliSecs()
Global fps_frames

;Mainloop
Repeat
;Move Particle
WW = ( WW + 2 ) Mod 360
XX# = Cos(WW)*10
YY# = Sin(WW)*2
PositionEntity KK,XX#,YY#,0
;timer
If timer + 25 < MilliSecs() Then
add_particle()
timer = MilliSecs()
EndIf
update_particle()
RenderWorld()
If guiButton("Ende",924,0,100,50)=1 Then
DeleteFile "particle_pic.JPG"
DeleteFile "leader_pic.JPG"
End
EndIf
DrawPointer(MouseX(),MouseY())
Flip
Cls
Until KeyHit(1)
DeleteFile "particle_pic.JPG"
DeleteFile "leader_pic.JPG"
End

;function add_particle
Function add_particle()
particle.particle = New particle
particle\sprite = CopyEntity(sprite)
particle\health = 100
ShowEntity particle\sprite
;move
PositionEntity particle\sprite, EntityX(KK), EntityY(KK), EntityZ(KK)
End Function

;function update_particle
Function update_particle()
For particle.particle = Each particle
If particle\health > 0 Then
particle\health = particle\health - 1
EntityAlpha particle\sprite,particle\health / 100.0
ScaleSprite particle\sprite,particle\health / 100.0,particle\health / 100.0
EndIf
If particle\health = 0 Then
FreeEntity particle\sprite
Delete particle
EndIf
Next
End Function

;FPS
Function Fps()
fps_frames=fps_frames+1
If MilliSecs()-fps_ms >= 1000 Then
fps_anzeige=fps_frames
fps_frames=0
fps_ms=MilliSecs()
EndIf
End Function

;GUI Functions
;Buttons
Function guiButton(Text$,x,y,w,h)
If h < FontHeight() Then h = FontHeight()
If w < StringWidth(Text$) Then w = StringWidth(Text$)

Color 255,255,255
If MouseOver(x,y,w,h) And MouseDown(1) Then Color 100,100,100
Rect x,y,w,h,1
Color 100,100,100
If MouseOver(x,y,w,h) And MouseDown(1) Then Color 255,255,255
Rect x+1, y+1, w-1, h-1,1
Color 198,198,198
If MouseOver(x,y,w,h) Then

EndIf
Rect x+1, y+1, w-2, h-2,1
Color 0,0,0
Text x + w/2 - (StringWidth(Text$)/2), y + h/2 - (FontHeight()/2), Text$
If MouseOver(x,y,w,h) And MouseDown(1) Then
Return 1
EndIf
End Function
;MouseOver
Function MouseOver(x,y,w,h)
If MouseX() > x And MouseX() < x+w And MouseY() > y And MouseY() < y+h Then Return 1
End Function

;Mousedraw
;;MOUSEDRAW;;
;Functions
Function DrawPointer(x,y)
LockBuffer()
Restore MouseImage
Read Width,Height
For y1 = 0 To Height-1
LCol = 0
For x1 = 0 To Width-1
Read Col1
If (x+x1)>=0 And (y+y1)>=0 And (x+x1)<GraphicsWidth() And (y+y1)<GraphicsHeight() Then
If Col1 Then
LCol = 6
Col = UDFColor(Col1)
WritePixelFast x+x1,y+y1,Col
Else
If LCol > 0 Then LCol = LCol - 1
EndIf
If (LCol > 0) And (Col1 = 0) Then
LCol2 = ReadPixelFast(x+x1,y+y1)
R = (LCol2 And $FF0000) / $10000 * ((6-LCol) * 8 + 52) / 100 + 10
G = (LCol2 And $FF00) / $100 * ((6-LCol) * 8 + 52) / 100 + 10
B = (LCol2 And $FF) * ((6-LCol) * 8 + 52) / 100 + 10
WritePixelFast x+x1,y+y1,R * $10000 + G * $100 + B
EndIf
EndIf
Next
Next
UnlockBuffer()
End Function
;Mouseimage
.MouseImage
Data 15,21
Data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 1,2,1,0,0,0,0,0,0,0,0,0,0,0,0
Data 1,2,2,1,0,0,0,0,0,0,0,0,0,0,0
Data 1,2,2,2,1,0,0,0,0,0,0,0,0,0,0
Data 1,2,2,2,2,1,0,0,0,0,0,0,0,0,0
Data 1,2,2,2,2,2,1,0,0,0,0,0,0,0,0
Data 1,2,2,2,2,2,2,1,0,0,0,0,0,0,0
Data 1,2,2,2,2,2,2,2,1,0,0,0,0,0,0
Data 1,2,2,2,2,2,2,2,2,1,0,0,0,0,0
Data 1,2,2,2,2,2,2,2,2,2,1,0,0,0,0
Data 1,2,2,2,2,2,2,1,1,1,1,1,0,0,0
Data 1,2,2,2,1,2,2,1,0,0,0,0,0,0,0
Data 1,2,2,1,1,2,2,1,0,0,0,0,0,0,0
Data 1,2,1,0,0,1,2,2,1,0,0,0,0,0,0
Data 1,1,0,0,0,1,2,2,1,0,0,0,0,0,0
Data 1,0,0,0,0,0,1,2,2,1,0,0,0,0,0
Data 0,0,0,0,0,0,1,2,2,1,0,0,0,0,0
Data 0,0,0,0,0,0,0,1,2,2,1,0,0,0,0
Data 0,0,0,0,0,0,0,1,2,2,1,0,0,0,0
Data 0,0,0,0,0,0,0,0,1,1,0,0,0,0,0
;...;


ist nichts besonderes...
B3D
MSVC++
DX9SDK
 

Edlothiol

BeitragSa, Mai 08, 2004 19:44
Antworten mit Zitat
Benutzer-Profile anzeigen
Sieht ganz lustig aus...
Aber das ganze Aussenrum mit Mauszeiger und Button wär nicht nötig gewesen, ein Druck auf Esc hätts auch getan...

sami

BeitragSo, Mai 09, 2004 11:48
Antworten mit Zitat
Benutzer-Profile anzeigen
hab bisschen damit rumgespielt Very Happy :
BlitzBasic: [AUSKLAPPEN]

;Interne Partikelengine by ChrisAttack
;(bearbeitet von Sami)

;Bild erstellen
;Particle
Global particle_pic=CreateImage(50,50)
SetBuffer ImageBuffer(particle_pic)
Color 0,0,255
Oval 0,0,50,50
Color 255,255,255
Oval 20,20,10,10
Color 255,255,0
Line 0,0,50,50
Line 0,50,50,50
Line 50,0,50,50


SaveImage particle_pic,"particle_pic.JPG"
;Leader
Global leader_pic=CreateImage(50,50)
SetBuffer ImageBuffer(leader_pic)
Color 0,0,255
Oval 0,0,50,50,1
SaveImage leader_pic,"leader_pic.JPG"


;Type "particle"
Type particle
Field sprite
Field health
Field red,gre,blu
Field typ
Field turn#
End Type

;Mousecolors
Dim UDFColor(2)
UDFColor(1) = $000000
UDFColor(2) = $FFFFFF

Graphics3D 1024,768,32,1
SetBuffer BackBuffer()

;Cam
cam = CreateCamera()
PositionEntity cam,0,0,-30

;Sprite
Global sprite = LoadSprite("particle_pic.JPG")
HideEntity sprite
Global leader = LoadSprite("leader_pic.JPG")

;Global Variables
Global timer
Global KK = CreatePivot()
EntityParent leader,KK
Global Winkel
;FPS
Global fps_anzeige
Global fps_ms=MilliSecs()
Global fps_frames

;Mainloop
Repeat
;Move Particle
WW = ( WW + 2 ) Mod 360
XX# = Cos(WW)*10
YY# = Sin(WW)*2
PositionEntity KK,XX#,YY#,0
;timer
If timer + 25 < MilliSecs() Then
add_particle()
timer = MilliSecs()
EndIf
update_particle()
RenderWorld()
If guiButton("Ende",924,0,100,50)=1 Then
DeleteFile "particle_pic.JPG"
DeleteFile "leader_pic.JPG"
End
EndIf
DrawPointer(MouseX(),MouseY())
Flip
Cls
Until KeyHit(1)
DeleteFile "particle_pic.JPG"
DeleteFile "leader_pic.JPG"
End

;function add_particle
Function add_particle()
particle.particle = New particle
particle\sprite = CopyEntity(sprite)
particle\health = 100
ShowEntity particle\sprite
particle\turn = Rnd(359)
particle\typ = Rand(0,5)
RotateEntity particle\sprite,Rnd(359),Rnd(180,359),0
;move
PositionEntity particle\sprite, EntityX(KK), EntityY(KK), EntityZ(KK)
End Function

;function update_particle
Function update_particle()
For particle.particle = Each particle
If particle\health > 0 Then
If particle\typ = 5
MoveEntity particle\sprite,0,0,.1
EndIf
particle\turn = particle\turn + 1
RotateSprite particle\sprite,particle\turn
particle\health = particle\health - 1
EntityAlpha particle\sprite,particle\health / 100.0
ScaleSprite particle\sprite,particle\health / 100.0,particle\health / 100.0
EntityColor particle\sprite,particle\red,particle\gre,particle\blu
particle\red = particle\health*3
particle\gre = particle\health/100.0
particle\blu = 100
EndIf
If particle\health = 0 Then
FreeEntity particle\sprite
Delete particle
EndIf
Next
End Function

;FPS
Function Fps()
fps_frames=fps_frames+1
If MilliSecs()-fps_ms >= 1000 Then
fps_anzeige=fps_frames
fps_frames=0
fps_ms=MilliSecs()
EndIf
End Function

;GUI Functions
;Buttons
Function guiButton(Text$,x,y,w,h)
If h < FontHeight() Then h = FontHeight()
If w < StringWidth(Text$) Then w = StringWidth(Text$)

Color 255,255,255
If MouseOver(x,y,w,h) And MouseDown(1) Then Color 100,100,100
Rect x,y,w,h,1
Color 100,100,100
If MouseOver(x,y,w,h) And MouseDown(1) Then Color 255,255,255
Rect x+1, y+1, w-1, h-1,1
Color 198,198,198
If MouseOver(x,y,w,h) Then

EndIf
Rect x+1, y+1, w-2, h-2,1
Color 0,0,0
Text x + w/2 - (StringWidth(Text$)/2), y + h/2 - (FontHeight()/2), Text$
If MouseOver(x,y,w,h) And MouseDown(1) Then
Return 1
EndIf
End Function
;MouseOver
Function MouseOver(x,y,w,h)
If MouseX() > x And MouseX() < x+w And MouseY() > y And MouseY() < y+h Then Return 1
End Function

;Mousedraw
;;MOUSEDRAW;;
;Functions
Function DrawPointer(x,y)
LockBuffer()
Restore MouseImage
Read Width,Height
For y1 = 0 To Height-1
LCol = 0
For x1 = 0 To Width-1
Read Col1
If (x+x1)>=0 And (y+y1)>=0 And (x+x1)<GraphicsWidth() And (y+y1)<GraphicsHeight() Then
If Col1 Then
LCol = 6
Col = UDFColor(Col1)
WritePixelFast x+x1,y+y1,Col
Else
If LCol > 0 Then LCol = LCol - 1
EndIf
If (LCol > 0) And (Col1 = 0) Then
LCol2 = ReadPixelFast(x+x1,y+y1)
R = (LCol2 And $FF0000) / $10000 * ((6-LCol) * 8 + 52) / 100 + 10
G = (LCol2 And $FF00) / $100 * ((6-LCol) * 8 + 52) / 100 + 10
B = (LCol2 And $FF) * ((6-LCol) * 8 + 52) / 100 + 10
WritePixelFast x+x1,y+y1,R * $10000 + G * $100 + B
EndIf
EndIf
Next
Next
UnlockBuffer()
End Function
;Mouseimage
.MouseImage
Data 15,21
Data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 1,2,1,0,0,0,0,0,0,0,0,0,0,0,0
Data 1,2,2,1,0,0,0,0,0,0,0,0,0,0,0
Data 1,2,2,2,1,0,0,0,0,0,0,0,0,0,0
Data 1,2,2,2,2,1,0,0,0,0,0,0,0,0,0
Data 1,2,2,2,2,2,1,0,0,0,0,0,0,0,0
Data 1,2,2,2,2,2,2,1,0,0,0,0,0,0,0
Data 1,2,2,2,2,2,2,2,1,0,0,0,0,0,0
Data 1,2,2,2,2,2,2,2,2,1,0,0,0,0,0
Data 1,2,2,2,2,2,2,2,2,2,1,0,0,0,0
Data 1,2,2,2,2,2,2,1,1,1,1,1,0,0,0
Data 1,2,2,2,1,2,2,1,0,0,0,0,0,0,0
Data 1,2,2,1,1,2,2,1,0,0,0,0,0,0,0
Data 1,2,1,0,0,1,2,2,1,0,0,0,0,0,0
Data 1,1,0,0,0,1,2,2,1,0,0,0,0,0,0
Data 1,0,0,0,0,0,1,2,2,1,0,0,0,0,0
Data 0,0,0,0,0,0,1,2,2,1,0,0,0,0,0
Data 0,0,0,0,0,0,0,1,2,2,1,0,0,0,0
Data 0,0,0,0,0,0,0,1,2,2,1,0,0,0,0
Data 0,0,0,0,0,0,0,0,1,1,0,0,0,0,0
;...;

ChrisAttack

BeitragSo, Mai 09, 2004 19:23
Antworten mit Zitat
Benutzer-Profile anzeigen
sieht gut aus! Very Happy
B3D
MSVC++
DX9SDK

Neue Antwort erstellen


Übersicht BlitzBasic Codearchiv

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group