Author Topic: BlitzMax test  (Read 839 times)

0 Members and 1 Guest are viewing this topic.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17296
  • Karma: 489
  • evil/good
    • View Profile
    • My Homepage
BlitzMax test
« on: May 07, 2011 »


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!!!!

Code: [Select]
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:

Offline rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2403
  • Karma: 402
    • View Profile
    • http://www.rbraz.com/
Re: BlitzMax test
« Reply #1 on: May 07, 2011 »
Back to the roots Shockie ? ;)

Works fine and fast for me.
rbz ^ Codigos
Challenge Trophies Won:

Offline TinDragon

  • Pentium
  • *****
  • Posts: 642
  • Karma: 24
    • View Profile
    • J2K's blog
Re: BlitzMax test
« Reply #2 on: May 07, 2011 »
Code: [Select]
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

Code: [Select]
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.



Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4365
  • Karma: 226
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: BlitzMax test
« Reply #3 on: May 08, 2011 »
Runs smooth and gentle here!
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17296
  • Karma: 489
  • evil/good
    • View Profile
    • My Homepage
Re: BlitzMax test
« Reply #4 on: May 08, 2011 »
Thanks :) and cheers for the tips!

Shockwave ^ Codigos
Challenge Trophies Won:

Offline LittleWhite

  • Senior Member
  • Amiga 1200
  • ********
  • Posts: 413
  • Karma: 30
  • It's me!
    • View Profile
Re: BlitzMax test
« Reply #5 on: May 09, 2011 »
Run fine on Win7 Geforce 8800

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

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17296
  • Karma: 489
  • evil/good
    • View Profile
    • My Homepage
Re: BlitzMax test
« Reply #6 on: May 09, 2011 »
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:

Offline Hotshot

  • Pentium
  • *****
  • Posts: 1814
  • Karma: 73
    • View Profile
Re: BlitzMax test
« Reply #7 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  :-\

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17296
  • Karma: 489
  • evil/good
    • View Profile
    • My Homepage
Re: BlitzMax test
« Reply #8 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: