I'm coding a simple text-based board game in Blitz Basic 2D v1.68, and for some reason the following code will after 60+ seconds completely lock up and not allow you to exit the program via the 'Escape Key' and you have to use CTRL+ALT+DEL to manually close it, even if its compiled it still locks up.
At first I thought it might be to do with the fonts, but even if you comment out the use of fonts, it still locks up -- I've put the code below, simply copy/paste -- I don't know why its locking up, it's really frustrating me when I'm so close to finishing the game.
Why does this code keep locking up for and how do I remedy it?
At first I thought it might be to do with the fonts, but even if you comment out the use of fonts, it still locks up -- I've put the code below, simply copy/paste -- I don't know why its locking up, it's really frustrating me when I'm so close to finishing the game.
; ############################################################## ; # ; # DRAW A LIST OF PLAYERS ; # @updated: 06-May-07 ; # ; ############################################################## ;@app constants Const app_name$ = "List Players" Const app_version$ = "v0.0.1" Const SCREEN_WIDTH = 800 Const SCREEN_HEIGHT = 600 Global player_on_turn = 1 ; ############################################################## ; @application setup AppTitle App_Title$() ; @graphics setup Graphics SCREEN_WIDTH, SCREEN_HEIGHT, 16, 2 SetBuffer BackBuffer(): SeedRnd (MilliSecs()) ; ############################################################## Initalise_Players() Big_Font() ; ############################################################## While Not KeyHit(1) Cls Draw_Players() Flip Wend End ; ############################################################## Type Player Field name$ ; string Field gender$ ; string Field is_ai ; boolean Field face ; pointer to the face image Field board_pos ; board position Field millions ; how many millions player has Field billions ; how many billions player has Field red ; RGB: Red Field green ; RGB: Green Field blue ; RGB: Blue ; Field myHand[totalcards] ; List of cards held by the player ; Field propHand[totalproperty]; List of property owned by the player End Type Function Initalise_Players() ; create human player Create_Player( "Player 1", "male", False) ; get a random gender ; get a random name based upon gender ; create a player using random name + gender, and make it AI. For i = 1 To 3 g$ = Random_Gender$() n$ = "AI " + i Create_Player( n$, g$, True) Next player_on_turn = Rand(1, 4) End Function Function Create_Player( name$, gender$="male", is_ai=False, board_pos=1, m=50, b=0 ) p.player = New player p\name$ = name$ p\gender$ = gender$ p\is_ai = is_ai If ( p\gender$ = "male" ) Then p\face = Rand(0, 8) If ( p\gender$ = "female" ) Then p\face = Rand(9, 17) p\board_pos = board_pos p\millions = m p\billions = b p\red = Rand(1,219) p\green = Rand(1,219) p\blue = Rand(1,219) End Function ; ############################################################## Function Random_Gender$() g = Rand(1, 2) If g = 1 Then Return "male" Else If g = 2 Then Return "female" Else RuntimeError "No gender generated" End If End If End Function Function Draw_Players() Local t = 150 Local v = 250 Local c = 0 Local i = 30 Local container_width = 200 Local container_height = 100 ; Draw List of Players For p.player = Each player c = c + 1 If ( player_on_turn = c ) Then ; Highlighted container Color p\red, p\green, p\blue Rect SCREEN_WIDTH-160, i, container_width, container_height, True Color 255, 255, 255 Text SCREEN_WIDTH - t, i , p\name$ Else ; Non-highlighted container Color p\red, p\green, p\blue Text SCREEN_WIDTH - t, i , p\name$ Color 255, 255, 255 End If ; ; Display Cash x = SCREEN_WIDTH - t y = i + 25 Text x,y, p\billions +"b" + " " + p\millions + "m" ; Display Cards and Properties small_font() Text x,y+25, "Cards: 0" Text x,y+45, "Properties: 0" big_font() i = i + (container_height + 20) Next End Function Function Big_Font() SetFont LoadFont("Arial",24) End Function Function Small_Font() SetFont LoadFont("Arial",18) End Function Function Custom_Font(fontsize=10) SetFont LoadFont("Arial",fontsize) End Function ; @application title Function App_Title$() Return app_name$ + " " +app_version$ End Function
Why does this code keep locking up for and how do I remedy it?