+ Reply to Thread
Results 1 to 6 of 6

Thread: Check out this BMax demo I made

  1. #1
    Senior Member
    Join Date
    Sep 2005
    Location
    Ohio, USA
    Posts
    712

    Talking Check out this BMax demo I made

    Code:
    Type TSolidBlock
    	Global List:TList
    	Global Image:TImage
    	
    	Field x#,y#,Xvel#,Yvel#
    	Field Size#
    	Field R,G,B		
    	Function CreateBlock(x#,y#,size#)
    
    		Local Block:TSolidBlock = New TSolidBlock
    		If List = Null List = CreateList()
    		List.AddLast Block
     		Block.R=Rnd(10,200)
     		Block.G=Rnd(10,200)
     		Block.B=Rnd(10,200)
    		Block.x# 			= x#
    		Block.y# 			= y#
    		Block.size# 		= size#
    
    	EndFunction
    
    	Function MoveBlocks()
    		If Not List Return
    		Local Block:TSolidBlock
    		For Block = EachIn List
    		If MouseDown(1) Friction#=0.0
    		If MouseDown(2) Friction#=Rnd(-4.5,4.5)
    
    		Dir#=Rnd(0,360)
    		Block.Xvel#:+ Cos(Dir#)*friction#
    		Block.Yvel#:+ Sin(Dir#)*friction#
    		Block.X# = Block.X# + Block.Xvel# - Friction#
    		Block.Y# = Block.Y# + Block.Yvel# - Friction#
    		Next
    	End Function
    
    
    
    	Function DrawBlocks()
    		If Not List Return
    		Local Block:TSolidBlock
    		For Block = EachIn List
    			SetColor(block.R,block.G,block.B)
    			DrawRect(block.x#-block.size#/2,block.y#-block.size#/2,block.size#,block.size#)
    		Next
    
    	End Function
    
    End Type
    
    Graphics 800,600,0
    
    Repeat
    	Cls
    
    	SetColor(255,255,255)
    	DrawText "Move the mouse",0,0
    	DrawText "LMB: Draw  |  RMB: Explode!",0,20
    	If MouseDown(1) TSolidBlock.CreateBlock(MouseX(),MouseY(),Rnd(2,10))
    	TSolidBlock.MoveBlocks()
    	TSolidBlock.DrawBlocks()
    	Flip
    Until KeyHit(Key_Escape)
    haha im all proud cuz its the first demo i made that uses vectors on multiple objects!

  2. #2
    Senior Member
    Join Date
    Nov 2004
    Posts
    182

    Default

    keke, i like it.

  3. #3
    Senior Member
    Join Date
    Jul 2004
    Posts
    2,186

    Default

    Hey, that's scarily similar to one of the first BMax programs one of my students made.

    I quite enjoyed the experience of just copying, pasting and compiling, by the way. Instant gratification.
    Anthony
    www.squashysoftware.com
    A slave to the ideal

  4. #4
    Senior Member
    Join Date
    Sep 2004
    Location
    Karlsruhe, Germany
    Posts
    408

    Default

    nice, but you should insert a FlushMem() Command into your mainloop else you get some memory leaks

  5. #5
    Senior Member
    Join Date
    Sep 2004
    Location
    Poole, Dorset. UK
    Posts
    319

    Default

    Apparently BMAX version 1.11 has automatic Memory management... You still need FlushMem in the main loop though.

  6. #6
    Senior Member
    Join Date
    Sep 2005
    Location
    Ohio, USA
    Posts
    712

    Default

    *opens bmax file*
    *adds flushmem()*
    *saves file*


+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts