Playing around with BlitzMax Demo...

BlitzMax Forums/BlitzMax Beginners Area/Playing around with BlitzMax Demo...

Hello all, I have BlitzPlus, but it seems Blitz Max has the features I want such as Transparency and rotation.. ect.

But I'm not too good with Blitz Plus yet and Blitz Max is quite complicated, half teh stuff I try now doesn't work.

Questions:
1. Modules? What the hell are those? Sets of Functions? Do I need to call out the modules I wana use?

2. The commands references is hard to browse in, I'm not quite sure what I'm doing really. Like is there somewhere with all the commands and what they do? I tryed finding "Graphics" but couldn't find it... I wanted to set it to windowed at 800x600. o.o

No idea. I still don't know why I jumped from bb to bm... well at least its recent and I like programming with confusing languages because I'm a nerd =) lets look at the main menu in bm for modules...

Module Reference
Welcome to the BlitzMax module reference.

This section describes all commands contained in BlitzMax modules.

For a description of the BlitzMax programming language, please see the BlitzMax language reference.

If you're new to BlitzMax, you might want to look at these modules first:
Audio - Sound effects and noises
Max2D - 2D graphics and rendering
Timers - Creating and using timers
Streams - Reading and writing data
File system - Managing the file system
Polled input - Getting keyboard and mouse input
Joystick - Getting joystick input


Ok I would take it that modules are just sections of information about commands. And to answer your second question: the documentation sucks. Resort to asking your noobish questions in the forums here. However you should be able to find things kind-of-easily. Lets see... help>modules>graphics> now lets double click on the graphics tab and see what crap it has to offer.

Ok 7th thing down the page under "functions". There you specify your resolution, bit depth, screen refreshrate and gfxmode. (like full screen or whatever, which is '1' by the way.)

I'm 15 and moved from bb cause it was kind of old and I never did much with that anyway. In about a month I've already learnt oop from a very good tutorial, collision code (with rotation) and some basic writing to files. I wouldn't say its that easy, anyway ask me for tutorials if you want any... I go through lots :D

- Welcome to the wide world of kicking ass!

Gimme all the tutorials! I wana learn BlitzMax abit before buying it, I have a dream menu I wana make, but it's not easy. I couldn't make it with B+ because it had no transparency and my lack of knowledge on how to time things... Let's say my overall lack of knowledge of the language lol.

Any tutorial for very simple games that are step by step and well explained? Because I'm the kind of guy who learns by seeing it first hand and knowing what everything does and why. o.o

Thanks for the help~

No, there aren't many tutorials for "how do I do xy step by step" ... for that type of all beginners, the old blitz versions are the better idea. You need to have some knowledge of what you do and of OO if you want to unleash BMs power ...

btw: How you want to achieve a menu with BM you couldn't have done with B+ is a mystery to me as the WinAPI simply does not allow alpha on its gadgets ...

Heres a good pdf that goes over all of the basics, then more cool stuff like arrays and oop and then some more basic (yet cool) stuff. This is a must read. Theres also lots of stuff on collision code I've yoinked off the internet and other various places...

One from a tutorial on bm
Graphics 640,480,0
AutoMidHandle True

Type ball
	Field image:timage
	Field name$

	Method New()
		Cls
		DrawOval 0,0,64,64
		image=CreateImage(64,64,1,DYNAMICIMAGE|MASKEDIMAGE)
		GrabImage image,0,0
	End Method
End Type

Local a:ball = New ball
Local b:ball = New ball
Local player:ball = New ball

a.name = "Ball a"
b.name = "Ball b"
player.name = "Ball player"

'cList is used to store a list of collided Objects
Local cList:Object[] = Null


SetBlend ALPHABLEND
		
While Not KeyHit(KEY_ESCAPE)
	Cls
	Local x%=MouseX()
	Local y%=MouseY()
	
	'Clear collision mask layer 1
	ResetCollisions(1)
	
	'Write image a.image into collision layer mask 1, and also store a link to Object a
	CollideImage a.image,50,50,0,0,COLLISION_LAYER_1,a
	DrawImage a.image,50,50

	'Write image b.image into collision layer mask 1, and also store a link to Object b
	CollideImage b.image,150,50,0,0,COLLISION_LAYER_1,b
	DrawImage b.image,150,50
	
	'Before we draw c.image, test if it will collide with anything in collision layer mask 1
	cList = CollideImage(player.image,x,y,0,COLLISION_LAYER_1,0)
	
	'Check the collision count
	If cList.length > 0
		'One or more collisions has happened!
		'change the alpha level as a visual indication
		SetAlpha .5
	Else
		SetAlpha 1.0
	End If
	
	'Draw player.image
	DrawImage player.image,x,y
	
	'Reset the alpha
	SetAlpha 1
	
	'Print a list of collision Objects names
	For Local i%=1 To cList.length
		'Remember, cList will contain Objects! We can cast them back to Types like so: ball(cList[x])
		'We could if needed check the Type of Object the player collided with using a cast check
		'If ball(cList[0]) = True 'cList[0] is a 'ball' Type
		DrawText("player.image collided with Object "+ball(cList[i-1]).name,5,150+(i*12))
	Next
	
	Flip
	
	'Free the old collision list
	cList = Null
'	FlushMem
Wend


Another one from I don't know where...
Strict

Local rot,x,y

Graphics 640,480

AutoMidHandle True	'image will rotate around it's center

Local image:TImage=LoadImage("gfx\player.bmp")
Local image2:TImage=LoadImage("gfx\bullet.bmp")

While Not KeyHit(KEY_ESCAPE)
	Cls
	ResetCollisions

' draw the first image at 5 times the size and on an arbitrary angle
	
	SetScale 5,5
	SetRotation 125

	DrawImage image,200,200

' add the first image to the first collision layer at same postion, rotation 
' and scale as it has just been drawn

	CollideImage image,200,200,0,0,6

' move the other image relative to the mouse and rotate it continuously

	x=MouseX()
	y=MouseY()-20
	rot:+1

	SetRotation rot
	DrawImage image2,x,y

' test the image at it's current rotation, scale and position with images
' that have been added to the first collision layer

	If CollideImage(image2,x,y,0,6,0)

' reset scale and rotation states so our text is drawn correctly		

		SetScale 1,1
		SetRotation 0
		DrawText "COLLISION!",20,20

	EndIf

	Flip
Wend


One I yoinked off the internet...
Graphics 1024,768,32,60,1

Global tList:TList = New TList

Type img
	Field image:timage
	Field x:Float,y:Float
	Field sx:Float,sy:Float
	Field r:Float,sr:Float
	
	Function Create:img(f:String)
		i:img = New img
		i.image = LoadImage(f)
		i.x		= Rnd(20,620)
		i.y		= Rnd(20,460)
		i.sx	= Rnd(-1,1)
		i.sy	= Rnd(-1,1)
		i.r		= Rnd(0,360)
		i.sr	= Rnd(-1,1)
		tList.Addlast i
		Return i
	End Function
	
	Method Update()
		x :+ sx
		y :+ sy
		r :+ sr
		If x>620 And sx>0
			sx = -sx
		ElseIf x<20 And sx<0
			sx = -sx			
		EndIf
		If y>460 And sy>0
			sy = -sy
		ElseIf y<20 And sy<0
			sy = -sy
		EndIf
		
		SetBlend ALPHABLEND
		SetScale 3,3
		SetRotation r
		SetColor 255,255,255
		
		' Draw this image in collision layer 1
		CollideImage(image,x,y,0,0,1)
		' Test all other images with collision layer 1
		For Local i:img = EachIn tList
			If i<>Self
				' This tests i.image for collision with layer 1
				If CollideImage(i.image,i.x,i.y,0,1,0)
					' We have a collision so let's make it red!
					SetColor 255,0,0
				EndIf
			EndIf
		Next
		' Clear all collision layers
		ResetCollisions()
		DrawImage image,x,y
	End Method
	
End Type

For j = 0 To 9
	i:img = img.create("gfx\bullet.bmp")
	MidHandleImage( i.image )
Next

Repeat
	
	Cls
	
	For i:img = EachIn tList
		i.Update()
	Next
	
	Flip
'	FlushMem
	
Until KeyHit(KEY_ESCAPE)


and another one I yoinked off the internet...
Global foodlayer = 1

Type Food
	Global List:TList = New TList
	Field x,y
		
	Function Create:Food(x,y)
		Local f:Food = New Food
		f.x=x
		f.y=y
		List.Addlast(f)
		Return f
	End Function
	
	Function UpdateAll()
		For Local f:Food = EachIn List
		f.Update()
		Next
	End Function 
	
	Method Render()
	SetColor 0,255,0
	DrawRect x,y,7,7
	SetColor 255,255,255
	
	End Method
	
	Method Update()
	
	Render()
	
	Local Collided:Object[], CollidedObj:Object, G:Gog
		
	Collided = CollideRect(X,Y,7,7,FoodLayer,0,Self)
	
	For CollidedObj = EachIn Collided
	If Gog(CollidedObj)
		Print 1
		G = Gog(CollidedObj)
		G.Energy:+10
		Food.List.Remove(Self)
		Exit
	End If
	Next
	
	End Method
	
End Type

Type Gog
	Field x,y
	Field Energy
	
	Function Create:gog(x,y)
		Local g:gog = New gog
		g.x=x
		g.y=y
		Return g
	End Function
	
	Method Update()
	
	DrawRect(x,y,7,7)
	DrawText Energy,x+10,y+10
	CollideRect(x,y,7,7,0,FoodLayer,Self)
	
	End Method
End Type

Graphics 800,600,0,-1



For Local I:Int = 0 To 30 
	Food.Create(Rnd(0,800),Rnd(0,600))
Next

Local G:Gog = Gog.Create(MouseX(),MouseY())

While Not KeyHit(key_escape)

ResetCollisions()

G.X = MouseX()
G.Y = MouseY()

G.Update()
Food.UpdateAll()



Flip
Cls
Wend


If you really want to go mad and kill yourself then theres more confusing things like asteroids in an hour or so that you probably don't care about in the tutorials forum so check out the tutorials section some time :)

but I would recommend staying with blitz-whatsit that you've already got.

It's called codebox.

Dreamora: Who said anything about gadgets? I didn't say it was a program's menu, or any rubish like that. B+ does not allow to make a Rect 50% transparent, it's a simple as that.

-----
Alot of things changes from B+ to Bmax, once I have a bigger grasp of B+ when I turn to Bmax it will be weird.

Ah ok. thought you meant real menus :-)
btw: even if it was a "real one": thanks to BMs event stuff you can make event based GUI without using WinGUI. Have created one myself as well for ingame usage, which supports draging and drag'n'drop as well as many events. But it does not use the WinAPI approach but C# approach with event function handles.

Cleaner and better structured way.

It's called codebox.

It is? *Checks faq, comes back and cleans old post* opps. So (code) and (codebox) I see... hehe, forum codes are funny. I bet you guys $5 that I can get perma banned the fastest for quote box towers :D

1) Module are sets of function. You can include only the ones you use to make your exe's smaller. This is difficult but FrameWork Assistant
You can even make your own which contain your functions as if they're part of the product with their own documentation.
2) Command reference has an Index under Help / Modules / Index which lists all in alphabetical order. In addition, there is Hotdocs and Assari's chm and Useful reasource page

Is flushmem suppose to do soemthing else then being brought as an error?

Flushmem isn't needed any more. Garbage collection is automatic. Any code you see with flushmem was written before the change.

oh ok, someone should tell the tech support to fix the topic:
Orientation guide for existing Blitz users