FrameWork... How TO ?

BlitzMax Forums/BlitzMax Beginners Area/FrameWork... How TO ?

sorry i don't know if already asked!

if i use framework to reduce the exe size the compiler give me errors...


prg sample...

-----------------------------------------

Strict

framework brl.max2d
framework brl.random

Graphics 640, 480, 32
Const MaxStar: Int = 30

Type tStar
Field X, Y : Int
Field Speed, Angle : Float
EndType

Global Stars: tStar[MaxStar]
Global StarSprite: tImage


StarSprite = LoadImage("Star.png", MASKEDIMAGE)

MidHandleImage StarSprite
SeedRnd MilliSecs()

For Local j:Int = 0 To MaxStar-1
Stars[j] = New tStar
Stars[j].X = Rand(0, 639)
Stars[j].Y = Rand(0, 479)
Stars[j].Angle = Rand(0, 360)
Stars[j].Speed = Rand(1, 3.5)
Next


While Not KeyHit(KEY_ESCAPE)
Cls
For Local J:Int = 0 To MaxStar-1
Stars[j].Angle :+ Stars[j].Speed
Stars[j].y :+ Stars[j].Speed

SetRotation Stars[j].Angle
DrawImage StarSprite, Stars[j].X, Stars[j].Y
If Stars[j].Y > 544 Then
stars[j].Y = -64
Stars[j].X = Rand(0, 639)
EndIf
If Stars[j].Angle > 360 Then Stars[j].Angle = 0
Next
Flip
Wend

End

---------------------------------------------------------

You can only use a single framework at a time. So you should perhaps make a module that imports specific modules needed for your game.

This compiles, but dies at the drawimage command.
Strict

framework brl.glmax2d
Import BRL.random
Import BRL.max2d
Import BRL.blitz

Graphics 640, 480, 0' 32
Const MaxStar: Int = 30

Type tStar
Field X, Y : Int
Field Speed, Angle : Float
EndType

Global Stars: tStar[MaxStar]
Global StarSprite: tImage


StarSprite = LoadImage("star.png", MASKEDIMAGE)

MidHandleImage StarSprite
SeedRnd MilliSecs()

For Local j:Int = 0 To MaxStar-1
Stars[j] = New tStar
Stars[j].X = Rand(0, 639)
Stars[j].Y = Rand(0, 479)
Stars[j].Angle = Rand(0, 360)
Stars[j].Speed = Rand(1, 3.5)
Next



While Not KeyHit(KEY_ESCAPE)
Cls
For Local J:Int = 0 To MaxStar-1
Stars[j].Angle :+ Stars[j].Speed
Stars[j].y :+ Stars[j].Speed

SetRotation Stars[j].Angle

DrawImage StarSprite, Stars[j].X, Stars[j].Y

If Stars[j].Y > 544 Then
stars[j].Y = -64
Stars[j].X = Rand(0, 639)
EndIf
If Stars[j].Angle > 360 Then Stars[j].Angle = 0
Next
Flip
Wend


The framework command doesn`t highlight here I`ve just noticed. Should it?

Jason.

it doesn't for me either.

That code will need a png loader, see the firepaint sample for an example use of Framework + Imports.