Greatest BlitzMax tips

BlitzMax Forums/BlitzMax Beginners Area/Greatest BlitzMax tips

MrPhil(Posted 2007) [#1]
Hi everyone. I'm new to BlitzMax and the community but I'm quickly become a big fan. I just learned about the SuperStrick command and it got me wondering what other tips I'm missing out on. Tell me what you've got!


GfK(Posted 2007) [#2]
Don't use the default IDE. Other options are available.


H&K(Posted 2007) [#3]
Dont Make everything an Object. Sometimes its overkill


deps(Posted 2007) [#4]
Type foo
    global list:tlist = createlist()

    ' ... other stuff

    Function draw_all()
      for local f:foo = eachin list
        f.draw()
      next
    EndFunction

    method new()
      list.addlast( self )
    endmethod

EndType

' .... game init
local bar:foo = new foo ' automatically added to the list

' ... Inside main loop
foo.draw_all() ' This will draw all foo's in the list



No need to call foo.init() or something, the list is created when the application/game starts.

I usually have one function for drawing stuff and another for updating logic. Always separate drawing and logic.

Everything written from memory while it's way past bedtime and I'm having a cold. So this might contains buggs and typos.

See the tutorials by Wave for some excellent stuff.


MrPhil(Posted 2007) [#5]
Alright! Thanks guys!

GFK: I looked at Blide but felt like it was over kill. What else is out there that I missed?

H&K: You mean Type right?

deps: Sweet! This I'll have to play with. I already run into some problems with trying to do this via a Create Method.

Keep them coming!


H&K(Posted 2007) [#6]
Err, no not really. There is sort of a difference between a Traditional "Type" and on OOP object/Type.

A Type (In general), is just a group of variables that belong together, this is nearly always a good thing. However for this group of variables to be an "Object" nearly (if not all) of the functions that use these varables need too be part of this "Type".

The problem comes when you originaly come to sit down to write the type and its functions, if you start with the idea that its going to be an "Object", then you (Well I anyway), spend ages writing all the possible Methods/Functions right then that this object might need.

If on the other hand you start with the idea that its just a group of variables you (well I again), just type in the names of the variables and then write functions that use this type When I need them

Now in the first case I have a complete "Object" that can be dropped into any program that needs such an object, and I can be quite sure that any methods/functions that the program might need are already writtem. (This is a good thing)
In the second case I quite quickly have a type and the Functions to use it, that this program needs. (this also is a good thing)
The skill comes in decideing when to do which. An exampple of overkill is...

When I first started to use Bmax, one of the first commmands I used would always be "Graphics Width,Height". So thinks I, I'll use a type "IntPair" and then have
Global ScreenDimentions:TIntPair = New TIntPair
ScreenDimentions.X = 640
ScreenDimentions.Y= 480
Graphics ScreenDimentions.x,ScreenDimentions.y
Some would say that this was already overkill, but flushed with the idea of my new "Type" becoming an "object" I decided to add a create() Function
Global ScreenDimentions:TIntPair = TintPair.Create (640,480)
Graphics ScreenDimentions.x,ScreenDimentions.y
Then I thought, I might want to sacle the values, so I wrote a Method to Multyply each field by a specific value, then I thought I might want to scale it differently in each direction, so I wrote a method to multiply it by another IntPair, then I thought I might want to Scale it differently in each direction, and return the result to a new IntPair etc
When really all I needed was a nice little type to hold Height and Width, (and some would say I didnt even need that)


GfK(Posted 2007) [#7]
GFK: I looked at Blide but felt like it was over kill. What else is out there that I missed?
If you haven't looked in the last couple of months, look again. Its much better than it used to be.

Project Studio is looking really nice (check the worklogs) - no Blitzmax version yet but apparently its coming. Actually it looks like it will give BLIde a serious run for its money.


CS_TBL(Posted 2007) [#8]
Here be me olde tip: avoid globals where you can. (not talking about those in-type globals like in deps example)


GfK(Posted 2007) [#9]
Here be me olde tip: avoid globals where you can.
Why?


CS_TBL(Posted 2007) [#10]
*grmblborkedforumthispostcango*


CS_TBL(Posted 2007) [#11]
namespace, and futureproofness

http://en.wikipedia.org/wiki/Global_variable

ps. the forum is borked or what?


tonyg(Posted 2007) [#12]
Take time to understand the Garbage Collector.
Make use of the tutorials forum and search function on these forums.
Check this to get up to speed with handy stuff.


Beaker(Posted 2007) [#13]
Use globals, but sparingly. Avoiding them often aids readability, memory use, bugs, speed.


MrPhil(Posted 2007) [#14]
@ H&K - yep, totally get what you mean. I'm a Test Driven Development programmer and follow the only code what you need philosophy.

@ Gfk - I'll check it out again. The main thing I wish the standard IDE did was intellisense like Visual Studio.

@ CS_TBL and Beaker - I agree, in fact I just found the public and private keywords for Types and was very happy indeed.

@tonyg - Thanks for the link!


H&K(Posted 2007) [#15]
The main thing I wish the standard IDE did was intellisense like Visual Studio.
I use BLide as well, and I would say that if you just close (Well put them on autopoop), all the seperate Panes, then all you have is a code window with intellisense.

The main benifit of BLide for me, is that if I think something is missing, I Post in one of Ziggys threads on these boards, and he either tells me why it cannot be added, or more often adds that feature. This level of support is amazing, and something I have never seen for any other product. (But probably users of IDeal will say the same of that)
(And I agree, you cannot really use a Object based Language without intellisense)


Grisu(Posted 2007) [#16]
- update the flat assembler
- use upx when creating executables
- don't try to understand the garbage collector in detail. ;)
- don't count on updates/fixes to arrive at the time you need them