• Welcome to Dark Bit Factory & Gravity.
 

BlitzMax test

Started by Shockwave, May 07, 2011

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Shockwave

Had a little play with Bmax for a few hours..

First impressions are good, it's really simple to get something on the screen just like other versions of Blitz but it has a binload of other stuff.  The IDE could be improved and there are some missing conventions that I am used to with other programming languages but they are very minor niggles.

Here's my obligatory Hello World which might end up being my Wireframe entry unless I get my act together soon!!!!


Strict

' ******************************************************************************************
' *                                                                                        *
' * I realise that a 3D starfield is my equivalent of a hello world.                       *
' * No apologies for that.                                                                 *
' * Shockwave/www.dbfinteractive.com                                                       *
' *                                                                                        *
' ******************************************************************************************

' *********************************************************************
' * Open Screen                                                       *
' *********************************************************************

SetGraphicsDriver GLMax2DDriver()
Const xres = 1024
Const yres = 768
Const halfX = 512
Const halfY = 384


Graphics xres,yres,32,60,GRAPHICS_BACKBUFFER
SetLineWidth(2)
SetBlend(LIGHTBLEND)
SetAlpha(0.75)
HideMouse

Const numStars = 7000

Global starX:Double[numstars]
Global starY:Double[numstars]
Global starZ:Double[numstars]
Global rS:Double[numStars]
Global gS:Double[numStars]
Global bS:Double[numStars]


' *********************************************************************
' * Main Loop                                                         *
' *********************************************************************
setstars()

Repeat

drawStars()
SetColor (255,255,255)

DrawText "-HELLO WORLD-",halfx-65,halfy

Flip(-1)
Cls

Until KeyDown(KEY_ESCAPE)

EndGraphics
End

' *********************************************************************
' * Render the starfield                                              *
' *********************************************************************

Function drawStars:Int()

Local lp,tx1,ty1,tx2,ty2,ic:Int

For lp=0 To numStars
tx1= Int((starX[lp] / starZ[lp])+halfX)
ty1= Int((starY[lp] / starZ[lp])+halfy)

tx2= Int((starX[lp] / (starZ[lp]+.5))+halfX)
ty2= Int((starY[lp] / (starZ[lp]+.5))+halfy)

If tx1>0 And tx1<xres And ty1>0 And ty1<yres Then

ic=(-(starZ[lp])+30)*5
SetColor (ic*rS[lp],ic*gS[lp],ic*bS[lp])
DrawLine tx1,ty1,tx2,ty2

End If

starZ[lp]=starZ[lp]-.15
If starZ[lp]<=0 Then starZ[lp]=starZ[lp]+30
Next

Return 1
End Function



' *********************************************************************
' * Initialise the starfield                                          *
' *********************************************************************

Function setStars:Int()

Local lp:Int

For lp=0 To numStars-1

starX[lp]=Rnd(-5000,5000)
starY[lp]=Rnd(-5000,5000)
starZ[lp]=Rnd(1,30)
rS[lp]=Rnd(0,1)
gS[lp]=Rnd(0,1)
bS[lp]=Rnd(0,1)
Next

Return 1
End Function
Shockwave ^ Codigos
Challenge Trophies Won:

Rbz

Back to the roots Shockie ? ;)

Works fine and fast for me.
Challenge Trophies Won:

TinDragon

Function setStars:Int()

You dont actually need to set the type of return to int since your not actually returning anything your using, you can just do

Function setStars()

then drop the return 1, not that it will reduce the exe size or anything, but by not having the :int your basicly telling it that the function doesnt need to return anything, like when you declare a void function in c/c++. Dont think it actually matters to much to bmax so go with whatever you prefer, just letting you know as I dont think the manual mentions it.



benny!

Runs smooth and gentle here!
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Shockwave

Thanks :) and cheers for the tips!

Shockwave ^ Codigos
Challenge Trophies Won:

LittleWhite

Run fine on Win7 Geforce 8800

Nice effect ;)
The demoscene will never die, never!

Shockwave

Thanks Littlewhite - I've put Bmax to one side for a little while though.  I think I'll come back to it as it looks pretty cool.
Shockwave ^ Codigos
Challenge Trophies Won:

Hotshot

Nice one and You can compress the files down to 573k
I don't know if You can compress down under 100k though  :-\

Shockwave

Quote from: Hotshot on May 17, 2011
Nice one and You can compress the files down to 573k
I don't know if You can compress down under 100k though  :-\

Yes, files of well under 100kb are possible :)
Shockwave ^ Codigos
Challenge Trophies Won: