Forum

> > Off Topic > A little BlitzMax help?
Forums overviewOff Topic overviewLog in to reply

English A little BlitzMax help?

2 replies
To the start Previous 1 Next To the start

old A little BlitzMax help?

DannyDeth
User Off Offline

Quote
Lol, i ahve been meaning to post this for quite a while but kept getting distracted ( "scripiting, programming" thread ). I wantd to know something about BlitzMax. I decided to buy it, even thought it costed a mighy fist, and would like to know what is wrong witht his test code i wrote:
1
2
3
4
5
6
7
8
9
10
11
12
Graphics 640,480,0
Global arot:Int
SetMaskColor 0,0,0
SetColor(255,255,255)
SetRotation( rot )
While Not KeyDown(Key_Escape)
	If KeyDown( Key_Up ) Then rot = rot + 1
	If KeyDown( Key_Down ) Then rot = rot - 1
	Global ak47=LoadImage( "ak2.bmp" )
	MidHandleImage( ak47 )
	Flip
Wend

It is meant to display a ak47 skin i drew up called ak2.bmp, it is in the same folder as the source file. But all i get is a black 640 by 480 screen. Im seriously confused.

old Re: A little BlitzMax help?

DC
Admin Off Offline

Quote
the drawimage command is missing...
(drawimage ak47,320,240)

moreover there is a huge mistake: you are loading and midhandling your image in the mainloop. this means that your computer loads the image from the file into your video ram again and again many times per second! this is totally pointless of course.

load your resources ONCE before you enter the main loop.

another tip: always use "superstrict" at the beginning of your code and always enter the type of the variable like
Global ak47:TImage
this might seem to be a lot of unnecessary work but it will save you loads of trouble when your project grows bigger.

old Re: A little BlitzMax help?

DannyDeth
User Off Offline

Quote
Ok, that explains a lot. I swear there are almost NO good tutorials for Blitzmax, the one i read seemed to say that the handle thingy had to do with the drawing. I had no idea at the time. lolz, i feel so stupid, like it's the first time i have ever coded

EDIT: YAY! It works, i changed the code to this to stop a very large magneta circle being drawn:
1
2
3
4
5
6
7
8
9
10
11
12
13
Graphics 640,480,0
Global rot:Int
SetMaskColor 255,0,255
SetColor(255,255,255)
Global ak47:TImage=LoadImage( "ak2.bmp" )
While Not KeyDown(Key_Escape)
	If KeyDown( Key_Up ) Then rot = rot + 1
	If KeyDown( Key_Down ) Then rot = rot - 1
	SetRotation( rot )
	MidHandleImage( ak47 )
	DrawImage( ak47, 320,240 )
	Flip; Cls
Wend
To the start Previous 1 Next To the start
Log in to replyOff Topic overviewForums overview