Gonna buy BlitzMax

Miscellaneous Forums/General Discussion/Gonna buy BlitzMax

I have been playing with the BlitzMax Demo.(Thought i would
never say that being a Blitz3D lover.)
but i have some work and extra money.(God bless my wife.)From the BlitzMax demo it looks like a very sexy language.Anyway heres me tinkering.

i forgot to say i am hoping to buy BlitzMax in the next few weeks.

'Example Code
'Robot in OpenGL
'Code:Nice_But_Dim
'*** More Comments than Code. ***

Framework brl.GLGraphics

SetGraphicsDriver GLGraphicsDriver()

Global ScreenWidth:Int=800
Global ScreenHeight:Int=600
Global ScreenDepth:Int=0 'Left this at zero or my laptop flickers like a bad b-movie,at fullscreen. Mirage3+ pure rubbish.
Global ScreenHertz:Int=60

Global angle:Float = 0.0
Global legAngle:Float[] = [0.0, 0.0]
Global armAngle:Float[] = [0.0, 0.0]

Global arm1:Float=True
Global arm2:Float=False
Global leg1:Float=True
Global leg2:Float=False

Graphics(ScreenWidth,ScreenHeight,ScreenDepth,ScreenHertz,GRAPHICS_BACKBUFFER | GRAPHICS_DEPTHBUFFER)
 
Start_GL()

'MAIN
Repeat 

	Render()
	
	Flip

Until AppTerminate() Or KeyHit (KEY_ESCAPE)

End
'END MAIN
	
Function Start_GL()
	glClearColor(0.0, 0.0, 0.2, 0.0)
	glClearDepth 1.0
	glDepthFunc(GL_LESS)
	glEnable(GL_DEPTH_TEST)
	glShadeModel(GL_SMOOTH)
	glViewport(0,0,ScreenWidth,ScreenHeight)
	glMatrixMode(GL_PROJECTION)
	glLoadIdentity()
	gluPerspective(45.0,1.3333,1.0,1000.0)
	glMatrixMode(GL_MODELVIEW)
End Function

Function Render()

        'Heres our rendering.
        'Clear the Color And Depth buffers
        'And reset our modelview matrix.
        
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        glLoadIdentity()

        'Increase rotation angle counter
        
        angle = angle + 1.0

        'Reset after we have completed a circle
        
        If angle >= 360.0 Then
        
                angle = 0.0

        EndIf

        glPushMatrix()
                glLoadIdentity()

                'Move Robot To 0,3,-30 , rotate the robot on
                'its y axis, draw the robot, And delete
                'the current matrix.
                
                glTranslatef(0.0, 3.0, -30.0)
                glRotatef(angle, 0.0, 1.0, 0.0)

                DrawRobot(0.0, 0.0, 0.0)

        glPopMatrix()

        glFlush()

End Function

Function DrawRobot(xPos:Float, yPos:Float, zPos:Float)

         'Variables For state of robots legs. True
         'means the leg is forward, And False means
         'the leg is back. The same applies To the
         'robots arm states.
        
        glPushMatrix()

                'This will draw our robot at the
                'desired coordinates.
                
                glTranslatef(xPos, yPos, zPos)

                'These three lines will draw the
                'various components of our robot.
                
                DrawHead(1.0, 2.0, 0.0)
                DrawTorso(1.5, 0.0, 0.0)

                glPushMatrix()

                'If the arm is moving forward we will increase
                'the angle; otherwise, we will decrease the
                'angle.
                
                If arm1
                
                        armAngle[0] = armAngle[0] + 1.0
                
                Else
                
                        armAngle[0] = armAngle[0] - 1.0
                
	      EndIf
	
                'Once the arm has reached its Max angle
                'in one direction, we want it To reverse
                'And change direction.
                
                If armAngle[0] >= 10.0 Then
                
                        arm1 = False

                EndIf
      
                If armAngle[0] <= -10.0 Then
                
                        arm1 = True

	      EndIf                

                'Here we are going To move the arm away
                'from the torso And rotate. This will
                'Create a walking effect.
                
                glTranslatef(0.0, -0.5, 0.0)
                glRotatef(armAngle[0], 1.0, 0.0, 0.0)

 	      'Time to draw the arm.
	
                DrawArm(2.5, 0.0, -0.5)

         glPopMatrix()

	Rem

		Same as above, For the Left arm.
		------------------------------------------
		
	End Rem

         glPushMatrix()

                'If the arm is moving forward we will increase
                'the angle, otherwise we will decrease the
                'angle
                
                If arm2
                
                        armAngle[1] = armAngle[1] + 1.0
                
                Else
                
                        armAngle[1] = armAngle[1] - 1.0
                
	      EndIf

                'Once the arm has reached its Max angle
                'in one direction, we want it To reverse
                'And change direction.
                
                If armAngle[1] >= 10.0 Then
                
                        arm2 = False

                EndIf
      
                If armAngle[1] <= -10.0 Then
                
                        arm2 = True

	      EndIf      
	
                'Here we are going To move the arm away
                'from the torso And rotate. This will
                'Create a walking effect.
                
                glTranslatef(0.0, -0.5, 0.0)
                glRotatef(armAngle[1], 1.0, 0.0, 0.0)

	      'Time to draw the arm.
	
                DrawArm(-1.5, 0.0, -0.5)

         glPopMatrix()

	        'Now its time To rotate the legs relative To the
	        'robots position in the world, this is the first
	        'leg, ie the Right one.
	        
         glPushMatrix()

                'If the leg is moving forward we will increase
                'the angle; otherwise, we will decrease the
                'angle.
                
                If leg1
                
                        legAngle[0] = legAngle[0] + 1.0
                
                Else
                
                        legAngle[0] = legAngle[0] - 1.0
                
	      EndIf
	
                'Once the leg has reached its Max angle
                'in one direction, we want it To reverse
                'And change direction.
                
                If legAngle[0] >= 10.0 Then
                
                        leg1 = False

                EndIf

                If legAngle[0] <= -10.0 Then
                
                        leg1 = True
                
	      EndIf

                'Here we are going To move the leg away
                'from the torso And rotate. This will
                'Create a walking effect.
                
                glTranslatef(0.0, -0.5, 0.0)
                glRotatef(legAngle[0], 1.0, 0.0, 0.0)


                'Time To draw the leg.
                
                DrawLeg(-0.5, -4.5, -0.5)

         glPopMatrix()

	Rem

		Same as above, For the Left leg.
		-----------------------------------------
		
	End Rem
        
         glPushMatrix()

                'If the leg is moving forward we will increase
                'the angle, otherwise we will decrease the
                'angle
                
                If leg2
                
                        legAngle[1] = legAngle[1] + 1.0
                
                Else
                
                        legAngle[1] = legAngle[1] - 1.0
                
	      EndIf
		
                'Once the leg has reached its Max angle
                'in one direction, we want it To reverse
                'And change direction.

                If legAngle[1] >= 10.0 Then 
                
                        leg2 = False

                EndIf

                If legAngle[1] <= -10.0 Then
                
                        leg2 = True

	      EndIf                

                'Here we are going To move the leg away
                'from the torso And rotate. This will
                'Create a walking effect.

                glTranslatef(0.0, -0.5, 0.0)
                glRotatef(legAngle[1], 1.0, 0.0, 0.0)

               'Time To draw the leg.

                DrawLeg(1.5, -4.5, -0.5)

         glPopMatrix()

 End Function

Function DrawCube(xPos:Float, yPos:Float, zPos:Float)

        glPushMatrix()
        glBegin(GL_POLYGON)

                'This is the top face
                glVertex3f(0.0, 0.0, 0.0)
                glVertex3f(0.0, 0.0, -1.0)
                glVertex3f(-1.0, 0.0, -1.0)
                glVertex3f(-1.0, 0.0, 0.0)

                'This is the front face
                glVertex3f(0.0, 0.0, 0.0)
                glVertex3f(-1.0, 0.0, 0.0)
                glVertex3f(-1.0, -1.0, 0.0)
                glVertex3f(0.0, -1.0, 0.0)

                'This is the Right face
                glVertex3f(0.0, 0.0, 0.0)
                glVertex3f(0.0, -1.0, 0.0)
                glVertex3f(0.0, -1.0, -1.0)
                glVertex3f(0.0, 0.0, -1.0)

                'This is the Left face
                glVertex3f(-1.0, 0.0, 0.0)
                glVertex3f(-1.0, 0.0, -1.0)
                glVertex3f(-1.0, -1.0, -1.0)
                glVertex3f(-1.0, -1.0, 0.0)

                'This is the bottom face
                glVertex3f(0.0, 0.0, 0.0)
                glVertex3f(0.0, -1.0, -1.0)
                glVertex3f(-1.0, -1.0, -1.0)
                glVertex3f(-1.0, -1.0, 0.0)

                'This is the back face
                glVertex3f(0.0, 0.0, 0.0)
                glVertex3f(-1.0, 0.0, -1.0)
                glVertex3f(-1.0, -1.0, -1.0)
                glVertex3f(0.0, -1.0, -1.0)

        glEnd()

        glPopMatrix()

End Function

Function DrawArm(xPos:Float, yPos:Float, zPos:Float)

        glPushMatrix()

                'Sets Color To red
                glColor3f(1.0, 0.0, 0.0)
                glTranslatef(xPos, yPos, zPos)

                'Creates 1 x 4 x 1 cube
                glScalef(1.0, 4.0, 1.0)

                DrawCube(0.0, 0.0, 0.0)

        glPopMatrix()

End Function

Function DrawHead(xPos:Float, yPos:Float, zPos:Float)

        glPushMatrix()

                'Sets Color To white
                glColor3f(1.0, 1.0, 1.0)
                glTranslatef(xPos, yPos, zPos)

                'Creates 2 x 2 x 2 cube
                glScalef(2.0, 2.0, 2.0)

                DrawCube(0.0, 0.0, 0.0)

        glPopMatrix()

End Function

Function DrawTorso(xPos:Float, yPos:Float, zPos:Float)

        glPushMatrix()

                'Sets Color To green
                glColor3f(0.0, 1.0, 0.0)
                glTranslatef(xPos, yPos, zPos)

                'Creates 3 x 5 x 1 cube
                glScalef(3.0, 5.0, 1.0)

                DrawCube(0.0, 0.0, 0.0)

        glPopMatrix()

End Function

Function DrawLeg(xPos:Float, yPos:Float, zPos:Float)

        glPushMatrix()

                'Sets Color To blue
                glColor3f(0.0, 0.0, 1.0)
                glTranslatef(xPos, yPos, zPos)

                'Creates 1 x 5 x 1 cube
                glScalef(1.0, 5.0, 1.0)

                DrawCube(0.0, 0.0, 0.0)

        glPopMatrix()

End Function


hope i have done the code blocks right.

Good, but it because it rocks.

Good decision.


Thought i would
never say that being a Blitz3D lover
Lol, why? It can be almost the same if you want it to be ;)

you can cocoon yourself with minib3D

>>Thought i would
never say that being a Blitz3D lover <<

Why not..B3D rulez..I hope Bmax will reach magnitude B3D did...B3D still rulez for many things, even Im now with Bmax and juicy Flow while testing LE..still proud to be B3D lover..

Echoing what Naughty says, Blitz3d does rule, I really like it, and Im also impressed by Bmax with Flow, that combo would be a great hit. Sorry Josh, but Flow seems to run alot faster for me

pretty good, a robot with animation - I had a look through the code.

I can see which part of the code draws the shapes and rotates the whole robot but I couldnt find the bit that rotates the arms and legs in a walking motion.

EDIT - oh yeah I see the armangle[] now

I like that -- I also like the way the code is laid out, very easy to follow.

how do you rotate the 'camera'?

There is no camera jeremy.That is why blitzmax looks sexy to me.

Mark Sibley has done the hard work for me,by creating the gl context.

and i can call it in one line of code by using SetGraphicsDriver GLGraphicsDriver()

that saves a lot of typng in it self. (God bless mark) i love it.

Try and create a gl context yourself a lot of typing

all the best mark.

if the screen was a camera you would have to make the robot move as if the camera was turning