PDA

View Full Version : swarm, a simple fun project to play with tbgl



kryton9
27-05-2008, 11:24
Just took a break tonight and wanted to do something fun.
Ended up with what I call Swarm.

It might take a second or two to load up and run, but as you can see the power of tbgl and thinbasic.
Few lines of code and can have a neat effect.

Petr Schreiber
27-05-2008, 11:52
Thanks for sharing Kent,

I really thought each particle has its own animation, only look into code revealed the terrible secret ;)
I like the name "swarmer", would be cool name for game character :)
There is something scary in that movement...


Petr

ErosOlmi
27-05-2008, 12:00
Thanks Kent.

You seems very inspired :D

kryton9
27-05-2008, 12:09
I couldn't sleep, so modded swarm into swarm 2.

Sometimes it starts out strange, other times fine... can't figure it out. But little bit of code and amazing what can appear.
Thanks guys for giving us fun language to play with!

kryton9
27-05-2008, 21:44
amazing just a few very minor changes and you end up with swarm 3 :)

Petr Schreiber
27-05-2008, 21:47
Thanks Kent,

interesting to watch how the screen is full in one moment and in another the number of lines goes down.


Petr

Petr Schreiber
27-05-2008, 21:58
When we have lines,

why not play a bit with line stipple?

It can be enabled using TBGL_UseLineStipple.

Then you can use TBGL_LineStipple to specify binary pattern to make line look like dotted, dashed ... you know the AutoCAD madness.

When combined with varying line width and blending ... you get swarm4 :)


Petr

kryton9
27-05-2008, 22:20
Thanks Petr, amazing just a few changes and the different look :) Thanks for joining in on the fun and giving us the tools to play with!

Petr Schreiber
27-05-2008, 22:36
Another little variation,

little bit wild, do not watch too much :)


Petr

ErosOlmi
27-05-2008, 22:51
Because you seems very inspired ...
http://www.youtube.com/watch?v=RZV4EKWAoQI

Petr Schreiber
27-05-2008, 23:04
Thanks Eros,

I am not good at TicTacToe :D
Very nice idea, ... but we still have that arkanoid pending ;)


Petr

ErosOlmi
27-05-2008, 23:14
I know that Simone is working on it but ... he is timid and do not want post his results ;D
I will push him a bit.

Petr Schreiber
28-05-2008, 10:16
I have no idea why he should be timid,

his first script published here was great and he helped me to catch some TBGL bugs features :)


Petr

kryton9
28-05-2008, 10:53
Petr, the swarm projects are fun, thanks for the cool demos!

Eros, I am working on something I think a lot of us here will enjoy. It will be finished in a day or two, at least the silent version. I think I will need Charles' help to break the silence, anyways I said more than I should have :)

sandyrepope
30-05-2008, 02:40
I've finally had a chance to try all the versions of swarm and I find that my favorite one is the first one. The one titled 'swarm'. It is so cool!

I've been thinking that maybe it would look really good using full screen.

Thanks for such a good script.
Sandy

matthew
30-05-2008, 03:24
Here you are Sandy, a Fullscreen Swarm. :)

UPDATED


'--- 2008-05-27
'--- swarm
'--- a fun thing to code for a break tonight
'--- by kent sarikaya

uses "tbgl"

'--- create and show window
' Create MessageBox
dim fullScreen as long
fullScreen = msgbox(0, "Would you like to Run in Fullscreen Mode?", %MB_YESNO or %MB_ICONINFORMATION, "Start FullScreen?")

DIM ScreenResWidth, ScreenResHeight, ScreenDepth AS LONG
tbgl_GetDesktopInfo ScreenResWidth, ScreenResHeight, ScreenDepth

dim hWnd as dword

select case fullScreen

' Create FullScreen Display, Return Handle.
case %IDYES
hWnd = tbgl_createwindowex("", ScreenResWidth, ScreenResHeight, ScreenDepth, %TBGL_WS_FULLSCREEN)
TBGL_ShowWindow

' Create Windowed Display, Return Handle.
case %IDNO
hWnd = tbgl_createwindowex("Swarm - Press 'Esc' to Quit", 640, 480, ScreenDepth, %TBGL_WS_WINDOWED)
TBGL_ShowWindow

end select

dim x as long
'--- resets status of all keys
tbgl_getasynckeystate(-1)

tbgl_color 0, 255, 0

makelist()

'--- main loop
while tbgl_iswindow(hwnd)

tbgl_clearframe

tbgl_camera 1, 2, 3, 0, 0, 0

tbgl_rotate gettickcount/100, 1,0,0
tbgl_calllist 100

tbgl_rotate gettickcount/125, 0,1,0
tbgl_calllist 100

tbgl_rotate gettickcount/75, 0,0,1
tbgl_calllist 100

tbgl_drawframe

'--- escape key to exit application
if tbgl_getwindowkeystate(hwnd, %vk_escape) then exit while

wend

tbgl_destroywindow

sub makelist()

tbgl_newlist 100
tbgl_pushmatrix
tbgl_beginpoly %gl_points
for x = 1 to 50000 '------------------------------you can adjust this number to control the number of swarmers
tbgl_vertex rndf(-5,5),rndf(-5,5),rndf(-5,5)
next
tbgl_endpoly
tbgl_popmatrix
tbgl_endlist

end sub

Petr Schreiber
30-05-2008, 09:41
Matthew,

thanks for the fullscreen version!
Just one thing - after window creation please always use tbgl_ShowWindow. In this case it might not have negative side effects not using it, but it is "good practice" recommended by help file too :)

Instead of 1 and 0 for fullscreen flag you can also use %TBGL_WS_FULLSCREEN or %TBGL_WS_WINDOWED.

I am sorry I am correcting you again :-[


Petr

matthew
30-05-2008, 10:33
Lol, don't worry I wasn't paying much attention when I posted that program, I should have been asleep. :D

The Fullscreen code was copied & pasted from an old program that I'd written, which is probably why it was incorrect.

I'll edit the original program in a few minutes. ;)

Petr Schreiber
30-05-2008, 10:50
Thanks :-[


Petr

sandyrepope
30-05-2008, 15:23
Thanks, I love the full screen version!

Sandy