"PARTICLE" oder auch nicht ^^

Previous topic - Next topic

WPShadow

Ach, ich mache das Ganze jetzt mal so:

Ich warte mal ab, bis ich mit meinem Nachhilfe - Lehrer zu den Vektoren gekommen bin und versuche dann mal was Eigenes zu machen.

Falls es funktioniert, dann is' gut, falls nicht, is' auch gut!  :nana:

Hoffentlich wird das was...  :D
AMD X2 4600, 2 GB Ram, ATI X1950 XTX, XP PRO SP2: GLB Premium 10.beta_dingsi, <(´.´<) Kirby Dance (>`.`)>
http://lostrevenant.blogspot.com
alea iacta est

backslider

Und ich versuch gerad ne 2D-PE zu bauen... Wenns geklappt hat, geb ichs dir ;) also den Sourcecode xD

WPShadow

Cooool!

Ich bin gespannt...
AMD X2 4600, 2 GB Ram, ATI X1950 XTX, XP PRO SP2: GLB Premium 10.beta_dingsi, <(´.´<) Kirby Dance (>`.`)>
http://lostrevenant.blogspot.com
alea iacta est

backslider

Hmmm...
Also bis jetzt sieht der Source so aus^^

Code (glbasic) Select

TYPE Vec2
x;y;
ENDTYPE

TYPE Color
r;g;b;
ENDTYPE

TYPE Particle
sprite%
position AS Vec2
direction AS Vec2
rotation
rotation_speed
color AS Color
scale
timeToLive

FUNCTION init: sprite%, pos_x, pos_y, dir_x, dir_y, angle, rotation_speed, col_r%=255, col_g%=255, col_b%=255, scale=1, ttl=5
self.sprite=sprite
self.position.x=pos_x; self.position.y=pos_y
self.direction.x=dir_x; self.direction.y=dir_y
self.rotation=angle
self.rotation_speed=rotation_speed
self.color.r=col_r
self.color.g=col_g
self.color.b=col_b
self.scale=scale
self.timeToLive=ttl
ENDFUNCTION

FUNCTION update:
INLINE
self.timeToLive--;
ENDINLINE

INC self.position.x, self.direction.x; INC self.position.y, self.direction.y
INC self.rotation, self.rotation_speed
ENDFUNCTION

FUNCTION draw:
ROTOZOOMSPRITE self.sprite, self.position.x, self.position.y, self.rotation, self.scale
ENDFUNCTION
ENDTYPE

TYPE ParticleEngine
origin AS Vec2
particle AS Particle
particles[] AS Particle
textures[]

FUNCTION particleCount%:
RETURN LEN(self.particles[])
ENDFUNCTION

FUNCTION update:
FOR i=0 TO LEN(self.particles[])-1
self.particles[i].update()

IF(self.particles[i].timeToLive <= 0)
DIMDEL self.particles[], i
DEC i, 1
ENDIF
NEXT
ENDFUNCTION

FUNCTION add:
LOCAL p AS Particle
p.init(RND(LEN(self.textures[])), mrnd(-100, 100), mrnd(-100, 100), RND(360), RND(360), RND(360), RND(10)*0.1, 255, 255, 255, RND(20)*0.1, mrnd(30,60))
ENDFUNCTION

FUNCTION draw:
FOR i=0 TO LEN(self.particles[])-1
PRINT "blub",self.particles[i].position.x,self.particles[i].position.y
NEXT
ENDFUNCTION
ENDTYPE

FUNCTION mrnd: mini, maxi
LOCAL rand
rand=RND(maxi - mini) + mini
RETURN rand
ENDFUNCTION


Aber ich krieg beim Aufruf der PE-Functions (update, draw) nen "Type is not declared"... (ist in einer Extra .gbas-Datei)
Weiß jemand woran das liegen kann?

WPShadow

Also in einer extra *.gbas funktioniert es noch nicht.

Wenn du das Ganze aber in der Hauptdatei drin hast, dann geht es problemlos!

Versuch's so mal!
AMD X2 4600, 2 GB Ram, ATI X1950 XTX, XP PRO SP2: GLB Premium 10.beta_dingsi, <(´.´<) Kirby Dance (>`.`)>
http://lostrevenant.blogspot.com
alea iacta est

BumbleBee

Quote from: backslider
Aber ich krieg beim Aufruf der PE-Functions (update, draw) nen "Type is not declared"... (ist in einer Extra .gbas-Datei)
Weiß jemand woran das liegen kann?

Ja, das ist glaube ich einer der Bugs die ich erwähnte. 

Cheers
The day will come...

CPU Intel(R) Core(TM) i5-3570k, 3.4GHz, AMD Radeon 7800 , 8 GB RAM, Windows 10 Home 64Bit

backslider

Hm, also bei mir kommt dann die Fehlermeldung:

Quote"ParticleSystem.gbas"(92) error : command not inside function or sub

backslider

So WPShadow...

Ich habs jetzt zumindest schonmal hinbekommen ne einfache 2D-ParticleEngine zu bauen :)

Hier der Source...

[attachment deleted by admin]

WPShadow

hehehe

Das sieht klasse aus!!!

Ich muß mir mal den Code durch sehen, wer weiß, was ich daraus bauen kann, falls ich den Code verstehe...
AMD X2 4600, 2 GB Ram, ATI X1950 XTX, XP PRO SP2: GLB Premium 10.beta_dingsi, <(´.´<) Kirby Dance (>`.`)>
http://lostrevenant.blogspot.com
alea iacta est

backslider

Also ganz grob erklärt hast du einfach einen Partikel mit seinen Eigenschaften (TYPE PARTICLE), wie z.B. Position, Lebensdauer UND eine "Partikelengine", welche den Partikel beliebig oft erstellt und sagt, was mit diesem passieren soll... Ich denke, das kann man auch noch einfacher schreiben, aber das war halt mal so auf die schnelle^^

Wenn ich mal Zeit habe, dann bau ich dir das auch nochmal in 3D, dann kannst du ja gucken, wo Unterschiede liegen ;)
Aber dank GLBasic wird der Partikel wohl einfach eine Position mehr bekommen (statt Vector2 (x,y) nen Vector3 (x,y,z))
und ein paar Wörter mehr im update der Partikelengine...
Kannst ja auch selbst mal probieren und erzählen, was du hinbekommen hast  :)

Gruß

Schranz0r

Und die Zeichenroutine muss geändert werden ;)
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

WPShadow

#26
Du meinst die Draw (2D) muß in Draw (3D) geändert werden? --> Soweit wäre es mir klar gewesen...  :booze:
AMD X2 4600, 2 GB Ram, ATI X1950 XTX, XP PRO SP2: GLB Premium 10.beta_dingsi, <(´.´<) Kirby Dance (>`.`)>
http://lostrevenant.blogspot.com
alea iacta est

backslider

Jo, das wird Schranz0r wohl meinen  :good:
Das habe ich schon als selbstverständlich gesehen^^