Page 4 of 4

Posted: Sat Feb 18, 2006 3:44 am
by Dark Mars Software
When someone clicks off my game and on another window and then back my game freezes. I know it has to do something with focus and lost focus but, what? Cold someone please give me example code?

Code: Select all

fixed by adding Event = WindowEvent() to my game loops.

Posted: Sat Feb 18, 2006 4:05 am
by MrMat
I think you've removed the code that was processing window events? In another post you had Event = WindowEvent() in the game loop. You'll need that so that windows messages get processed.

Posted: Sat Feb 18, 2006 4:17 am
by Dark Mars Software
Opps, forgot that i removed that when i added the new anti-cpu overload code. I thought i didn't need it. Thanks.

Posted: Sun Feb 19, 2006 1:54 am
by Dark Mars Software

Code: Select all

Declare TwoPlayerGame() 
Declare TitleScreen() 
Declare Timer(x) 
Declare TimeAttackScoreMod() 
Declare TimeAttackGame() 
Declare ResetScores() 
Declare ResetLevel() 
Declare PrintScores() 
Declare PositionObjects() 
Declare Player2Movement() 
Declare Player1Movement() 
Declare OnePlayerGame() 
Declare MoveBall() 
Declare MountAComebackMod() 
Declare MountAComebackGame() 
Declare LoadSprites() 
Declare LoadSounds() 
Declare ComputerAI() 
Declare CleanUp() 
Declare CheckForPause() 
Declare BallBouncing() 
;Initialize the keyboard libraries 
If InitKeyboard() = 0 
  MessageRequester("Error",  "Can't open DirectX 7", 0) 
  End 
EndIf 

;Initialize the sprite libraries 
If InitSprite() = 0 
  MessageRequester("Error",  "Can't open DirectX 7", 0) 
  End 
EndIf 

Global sound_possible.b 

;Initialize the sound libraries 
If InitSound() = 0 
  sound_possible  = 0 
Else 
  sound_possible  = 1 
EndIf 

;Initalize the Procedures 
;SetFrameRate(30) 

;setup the player structure 
Structure Player 
X_Position.w 
Y_Position.w 
Score.b 
EndStructure 

;create player 1 object 
Global Player1.Player 

;create player 2 object 
Global Player2.Player 

;setup the ball structure 
Structure Ball 
X_Position.w 
Y_Position.w 
X_Velocity.b 
Y_Velocity.b 
EndStructure 

;crreate ball object 
Global Ball.Ball 

Ball\X_Velocity = 3 

Ball\Y_Velocity = 3 

;player muted sound 
Global mute.b 
;used to determine if a game is finished 
Global done.b 

;used for the Time Attack Timer 
Global Timer 

Global thread_id.l

;setup load balance variable 
Global dynamic_delay_set 
dynamic_delay_set = 50 

TitleScreen() 

Procedure BallBouncing() 
  ;if the ball is at the left edge bounce it off 
  If Ball\X_Position  > 432 
    Ball\X_Position  = 431 
    Ball\X_Velocity  =  - Ball\X_Velocity 
  EndIf 
  
  ;if the ball is at the right edge bounce it off 
  If Ball\X_Position  < 10 
    Ball\X_Position  = 11 
    Ball\X_Velocity  =  - Ball\X_Velocity 
  EndIf 
EndProcedure 

Procedure CheckForPause() 
  ;check for keyboard input 
  ExamineKeyboard() 
  
  ;if either player presses P 
  If KeyboardPushed(#PB_Key_P) 
    
    ;wait 75ms 
    Delay(75) 
    
    ;clear the screen to black 
    ClearScreen(Black) 
    If StartDrawing(ScreenOutput()) 
      
      ;let the user know the game is paused 
      DrawText(300, 100,  "Press P to unpause") 
      StopDrawing() 
      FlipBuffers() 
      Repeat 
        ExamineKeyboard() 
        Delay(75) 
        
        ;and wait until the user unpauses it by pressing P again 
      Until KeyboardPushed(#PB_Key_P) 
    EndIf 
  EndIf 
EndProcedure 

Procedure CleanUp() 
  ;The game is finished so remove all the sprites And sounds from memory 
  
  ;remove player paddles sprite 
  FreeSprite(0) 
  
  ;remove ball sprite 
  FreeSprite(1) 
  
  ;if no sound was possible then the sound files 
  ;weren't loaded and we don't need To unload them. 
  If sound_possible  < >0 
    
    ;remove applause.wav 
    FreeSound(0) 
    
    ;remove boink1.wav 
    FreeSound(1) 
    
    ;remove boink2.wav 
    FreeSound(2) 
    
    ;remove explosion.wav 
    FreeSound(3) 
  EndIf 
EndProcedure 

Procedure ComputerAI() 
  ;if the ball is to the left of the computers paddle, move the computers paddle left 
  If Ball\X_Position  < Player2\X_Position 
    Player2\X_Position  - 5 
  EndIf 
  
  ;if the ball is to the right of the computers paddle, move the computers paddle right 
  If Ball\X_Position  > Player2\X_Position 
    Player2\X_Position  + 5 
  EndIf 
EndProcedure 

Procedure LoadSounds() 
  ;if we were able to initalize the sound drivers successfully 
  If sound_possible = 1 
    
    ;load the sound effect 
    LoadSound(0,  "Sound\applause.wav") 
    
    ;if the sound effect couldn't be loaded because the file doesn't excist 
    If IsSound(0) = 0
      
      ;give an error message and quit 
      MessageRequester("Error",  "Can't open Sound\applause.wav", 0) 
      End 
    EndIf 
    
    ;load the sound effect 
    LoadSound(1,  "Sound\boink1.wav") 
    
    ;if the sound effect couldn't be loaded because the file doesn't excist 
    If IsSound(1) = 0
      
      ;give an error message and quit 
      MessageRequester("Error",  "Can't open Sound\boink1.wav", 0) 
      End 
    EndIf 
    
    ;load the sound effect 
    LoadSound(2,  "Sound\boink2.wav") 
    
    ;if the sound effect couldn't be loaded because the file doesn't excist 
    If IsSound(2) = 0
      
      ;give an error message and quit 
      MessageRequester("Error",  "Can't open Sound\boink2.wav", 0) 
      End 
    EndIf 
    
    ;load the sound effect 
    LoadSound(3,  "Sound\explosion.wav") 
    
    ;if the sound effect couldn't be loaded because the file doesn't excist 
    If IsSound(3) = 0
      
      ;give an error message and quit 
      MessageRequester("Error",  "Can't open Sound\explosion.wav", 0) 
      End 
    EndIf 
  EndIf 
EndProcedure 

Procedure LoadSprites() 
  ;load the sprite 
  LoadSprite(0,  "Sprite\bat.bmp", 0) 
  
  ;if the sprite couldn't be loaded because the file doesn't excist 
  If IsSprite(0) = 0 
    
    ;give an error message and quit 
    MessageRequester("Error",  "Can't open Sprite\bat.bmp", 0) 
    End 
  EndIf 
  
  ;otherwise set the player sprites initial positions 
  Player1\X_Position  = 300 
  player2\X_Position  = 300 
  
  ;load the sprite 
  LoadSprite(1,  "Sprite\ball.bmp", 0) 
  
  ;if the sprite couldn't be loaded because the file doesn't excist 
  If IsSprite(1) = 0 
    
    ;give an error message and quit 
    MessageRequester("Error",  "Can't open Sprite\ball.bmp", 0) 
    End 
  EndIf 
  
  ;otherwise set the ball sprite initial position 
  Ball\X_Position  = 240 
  ball\Y_Position  = 320 
EndProcedure 

Procedure MountAComebackGame() 
  ;if a window was opened successfully 
  If OpenWindow(0, 0, 0, 480, 640, #PB_Window_SystemMenu, "Pong Master v0.1 - Mount-A-Comeback") 
    
    ; Now, open a 640*480 - 16 bits (65000 colours) screen 
    OpenWindowedScreen(WindowID(0),  0, 0, 480, 640, 0, 1, 1) 
    
    ;Load the Sprites into Memory 
    LoadSprites() 
    
    ;Load the Sound Effects into Memory 
    LoadSounds() 
    
    ;Apply Mount-A-Comeback Mod 
    MountAComebackMod() 
    
    ;Set Done to 0 
    done  = 0 
    
    ;Position the Sprites 
    PositionObjects() 
    
    ;start the game loop 
    Repeat 

    ;Process Window Events 
    Event = WindowEvent() 
      
      ;if the user tries to close the window then go to the title screen 
      If Event = #PB_Event_CloseWindow 
      done = 1 
      EndIf 
      
      ;Delay the game 1 millisecand 
      Delay(1) 
      
      ;Game Interface Procedures 
      CheckForPause() 
      BallBouncing() 
      MoveBall() 
      Player1Movement() 
      ComputerAI() 
      PrintScores() 
      
      ; Inverse the buffers (the back become the front (visible)... And we can do the rendering on the back) 
      
      FlipBuffers() 
      
     loopcounter + 1 

If loopcounter >= dynamic_delay_set 
   Delay(1) 
   loopcounter = 0 
EndIf 
      
    Until KeyboardPushed(#PB_Key_Escape) Or done  = 1 
    
    ;the player just won so wait a few secs so the player can see the win message 
    Delay(1000) 
    
    ;The game is finished so remove all the sprites and sounds from memory 
    CleanUp() 
    
    ;and close the window 
    CloseWindow(0) 
    
    ;close the current screen 
    CloseScreen() 
    
    ;and reopen the titlescreen 
    TitleScreen() 
    
  Else 
    
    ;otherwise let the user know we couldn't open the game window 
    MessageRequester("Error",  "Can't open a 480*640 - 16 bit screen !", 0) 
  EndIf 
  
  ;remove all the sprites and sounds from memory 
  CleanUp() 
EndProcedure 

Procedure MountAComebackMod() 
  ;Modification Code for Mount-A-Comeback Game 
  
  ;set player 1's score to 13 
  Player1\Score  = 13 
  
  ;set player 2's score to 14 
  Player2\Score  = 14 
EndProcedure 

Procedure MoveBall() 
  Ball\X_Position  = Ball\X_Position  + Ball\X_Velocity 
  Ball\Y_Position  = Ball\Y_Position  + ball\Y_Velocity 
  
  ;if the ball gets past player 2's paddle player 1 scores a point 
  If Ball\Y_Position  < 10 
    Player1\Score  + 1 
    
    ;and reset all the sprites position 
    ResetLevel() 
  EndIf 
  
  ;if the ball gets past player 1's paddle player 2 scores a point 
  If Ball\Y_Position  > 615 
    Player2\Score  + 1 
    ;and reset all the sprites position 
    ResetLevel() 
  EndIf 
  
  ;if the ball collides with player 1's paddle, bounce the ball off it 
  If SpriteCollision(1, Ball\X_Position, Ball\Y_Position, 0, Player1\X_Position, 610) 
    Ball\X_Position  = Player1\X_Position  + 5 
    Ball\Y_Velocity  =  - Ball\Y_Velocity 
  EndIf 
  
  ;if the ball collides with player 2's paddle, bounce the ball off it 
  If SpriteCollision(1, Ball\X_Position, Ball\Y_Position, 0, Player2\X_Position, 15) 
    Ball\X_Position  = Player2\X_position  + 5 
    Ball\Y_Velocity  =  - Ball\Y_velocity 
  EndIf 
EndProcedure 

Procedure OnePlayerGame() 
  ;if a window was successfully opened 
  If OpenWindow(0, 0, 0, 480, 640, #PB_Window_SystemMenu, "Pong Master v0.1 - One Player") 
    
    ; Now, open a 640*480 - 16 bits (65000 colours) screen 
    OpenWindowedScreen(WindowID(0),  0, 0, 480, 640, 0, 1, 1) 
    
    ;Load the Sprites into Memory 
    LoadSprites() 
    
    ;Load the Sound Effects into Memory 
    LoadSounds() 
    
    ;ResetTheScores 
    ResetScores() 
    
    ;Position the Sprites 
    PositionObjects() 
    
    ;set done to 0 
    done  = 0 
    
    ;start the game loop 
    Repeat 
      
      ;Process Window Events 
    Event = WindowEvent() 
      
      ;if the user tries to close the window then go to the title screen 
      If Event = #PB_Event_CloseWindow 
      done = 1 
      EndIf 
      
      ;Delay the game 1 millisecand 
      Delay(1) 
      
      ;Game Interface Procedures 
      CheckForPause() 
      BallBouncing() 
      MoveBall() 
      Player1Movement() 
      ComputerAI() 
      PrintScores() 
      
      ; Inverse the buffers (the back become the front (visible)... And we can do the rendering on the back) 
      
      FlipBuffers() 
      
      ;increase the loop check by 1 
      loopcounter + 1 
     ;if the game has looped 50 times then delay for 1 second 
    If loopcounter >= dynamic_delay_set 
   Delay(1) 
   loopcounter = 0 
   EndIf 
      
    Until KeyboardPushed(#PB_Key_Escape)Or done  = 1 
    
    ;the player just won so wait a few secs so the player can see the win message 
    Delay(1000) 
    
    ;The game is finished so remove all the sprites and sounds from memory 
    CleanUp() 
    
    ;close the window 
    CloseWindow(0) 
    
    ;close the current screen 
    CloseScreen() 
    
    ;and reopen the titlescreen 
    TitleScreen() 
    
  Else 
    MessageRequester("Error",  "Can't open a 480*640 - 16 bit screen !", 0) 
  EndIf 
  
  ;remove all the sprites And sounds from memory 
  CleanUp() 
EndProcedure 

Procedure Player1Movement() 
  
  ;check for keyboard input 
  ExamineKeyboard() 
  
  ;if player 1 presses left 
  If KeyboardPushed(#PB_Key_Left)And Player1\X_Position  >  - 1 
    Player1\X_Position  - 5 
  EndIf 
  
  ;if player 1 presses right 
  If KeyboardPushed(#PB_Key_Right)And Player_1_Position  < 432 
    Player1\X_Position  + 5 
  EndIf 
  
  ;update the sprites position 
  PositionObjects() 
EndProcedure 

Procedure Player2Movement() 
  ;check for keyboard input 
  ExamineKeyboard() 
  
  ;if player 2 presses left 
  If KeyboardPushed(#PB_Key_A)And Player2\X_Position  >  - 1 
    Player2\X_Position  - 5 
  EndIf 
  
  ;if player 2 presses right 
  If KeyboardPushed(#PB_Key_S)And Player2\X_Position  < 432 
    Player2\X_Position  + 5 
  EndIf 
  
  ;update the sprites position 
  PositionObjects() 
EndProcedure 

Procedure PositionObjects() 
  ;Clear the screen to Black 
  ClearScreen(Black) 
  
  ;Position Player 1's Sprite 
  DisplaySprite(0,  Player1\X_Position, 610) 
  
  ;Position Player 2's Sprite 
  DisplaySprite(0,  Player2\X_Position, 15) 
  
  ;Position the Ball Sprite 
  DisplaySprite(1,  Ball\X_Position, Ball\Y_Position) 
EndProcedure 

Procedure PrintScores() 
  ;If no one has won print the current scores 
  If (Player1\Score  < >15)Or (Player2\Score  < >15) 
    If StartDrawing(ScreenOutput()) 
      
      ;draw player 1's score at x 400 y 100 
      DrawText(400, 100, Str(Player1\Score)) 
      
      ;draw a dash at x 420 y 100 
      DrawText(420, 100, "-") 
      
      ;draw player 2's score at x 430 y 100 
      DrawText(430, 100, Str(Player2\Score)) 
      StopDrawing() 
    EndIf 
  EndIf 
  
  ;if Player 1 has won 
  If Player1\Score  = 15 
    If StartDrawing(ScreenOutput()) 
      
      ;draw the "Player 1 has won" win message at x 350 y 100 
      DrawText(350, 100, "Player 1 has Won") 
      StopDrawing() 
      
      ;since someone won set done to 1 to close the game window 
      done  = 1 
    EndIf 
  EndIf 
  
  ;if Player 2 has won 
  If Player2\Score  = 15 
    If StartDrawing(ScreenOutput()) 
      
      ;draw the "Player 2 has won" win message at x 350 y 100 
      DrawText(350, 100, "Player 2 Has Won") 
      StopDrawing() 
      
      ;since someone won set done to 1 to close the game window 
      done  = 1 
    EndIf 
  EndIf 
EndProcedure 

Procedure ResetLevel() 
  ;reset player 1's paddle sprite position 
  Player1\X_Position  = 300 
  
  ;reset player 2's paddle sprite position 
  Player2\X_Position  = 300 
  
  ;reset the ball sprite's x position 
  Ball\X_Position  = 240 
  
  ;reset the ball sprite's y position 
  ball\Y_Position  = 320 
EndProcedure 

Procedure ResetScores() 
  ;we're starting a new game so reset player 1's score to 0 
  Player1\Score  = 0 
  
  ;we're starting a new game so reset player 2's score to 0 
  Player2\Score  = 0 
EndProcedure 

Procedure TitleScreen() 
  ;- Window Constants 
  ; 
  Enumeration 
  #MainMenu 
  EndEnumeration 
  
  ;- Gadget Constants 
  ; 
  Enumeration 
  #OnePlayerGame 
  #TwoPlayerGame 
  #MountAComeback 
  #TimeAttack 
  #Quit 
  EndEnumeration 
  
  ;if the window was opened successfully 
  If OpenWindow(#MainMenu, 216, 0, 209, 216, #PB_Window_SystemMenu  | #PB_Window_TitleBar  | #PB_Window_ScreenCentered , "Pong Master - Main Menu") 
    
    ;create gadget list 
    If CreateGadgetList(WindowID(#MainMenu)) 
      ButtonGadget(#OnePlayerGame,  10, 10, 180, 30, "1 Pplayer Game") 
      ButtonGadget(#TwoPlayerGame,  10, 50, 180, 30, "2 Player Game") 
      ButtonGadget(#MountAComeback,  10, 90, 180, 30, "Mount-A-Comeback") 
      ButtonGadget(#TimeAttack,  10, 130, 180, 30, "Time Attack") 
      ButtonGadget(#Quit,  10, 170, 180, 30, "Quit") 
      
    EndIf 
  EndIf 
  
  Repeat ; Start of the event loop 
    
    Event  = WaitWindowEvent(); This line waits until an event is received from Windows 
    
    WindowID  = EventWindow(); The Window where the event is generated, can be used in the gadget procedures 
    
    GadgetID  = EventGadget(); Is it a gadget event? 
    
    EventType  = EventType(); The event type 
    
    ;You can place code here, and use the result as parameters for the procedures 
    
    If Event  = #PB_Event_Gadget 
      
      ;if the One Player Button was pressed goto OnePlayerGame Procedure 
      If GadgetID  = #OnePlayerGame 
        OnePlayerGame() 
        
        ;if the Two Player Button was pressed goto TwoPlayerGame Procedure 
      ElseIf GadgetID  = #TwoPlayerGame 
        TwoPlayerGame() 
        
        ;if the Mount-A-Comeback Button was pressed goto MountAComeback Procedure 
      ElseIf GadgetID  = #MountAComeback 
        MountAComebackGame() 
        
        ;if the Time Attack Button was pressed goto TimeAttack Procedure 
      ElseIf GadgetID  = #TimeAttack 
        TimeAttackGame() 
        ;if the Quit Button was pressed quit 
      ElseIf GadgetID  = #Quit 
        End 
      EndIf 
      
    EndIf 
    
  Until Event  = #PB_Event_CloseWindow ; End of the event loop 
EndProcedure 

Procedure TimeAttackGame() 
;if a window was successfully opened 
  If OpenWindow(0, 0, 0, 480, 640, #PB_Window_SystemMenu, "Pong Master v0.1 - One Player") 
    
    ; Now, open a 640*480 - 16 bits (65000 colours) screen 
    OpenWindowedScreen(WindowID(0),  0, 0, 480, 640, 0, 1, 1) 
    
    ;Load the Sprites into Memory 
    LoadSprites() 
    
    ;Load the Sound Effects into Memory 
    LoadSounds() 
    
    ;ResetTheScores 
    ResetScores() 
    
    ;Position the Sprites 
    PositionObjects() 
    
    ;set done to 0 
    done  = 0 
    
    Timer = 120 
    
    thread_id = CreateThread(@Timer(),1000) ; Fires the procedure every 1 second. 
    
    ;start the game loop 
    Repeat 
      
      ;Process Window Events 
    Event = WindowEvent() 
      
      ;if the user tries to close the window then go to the title screen 
      If Event = #PB_Event_CloseWindow 
      done = 1 
      EndIf 
      
      ;Delay the game 1 millisecand 
      Delay(1) 
      
      ;Game Interface Procedures 
      CheckForPause() 
      BallBouncing() 
      MoveBall() 
      Player1Movement() 
      ComputerAI() 
      TimeAttackScoreMod() 
      
      ; Inverse the buffers (the back become the front (visible)... And we can do the rendering on the back) 
      
      FlipBuffers() 
      
      ;increase the loop check by 1 
      loopcounter + 1 
     ;if the game has looped 50 times then delay for 1 second 
    If loopcounter >= dynamic_delay_set 
   Delay(1) 
   loopcounter = 0 
   EndIf 
      
    Until KeyboardPushed(#PB_Key_Escape)Or done  = 1 
    
    ;the player just won so wait a few secs so the player can see the win message 
    Delay(1000) 
    
    ;The game is finished so remove all the sprites and sounds from memory 
    CleanUp() 
    
    KillThread(thread_id) 
    
    ;close the window 
    CloseWindow(0) 
    
    ;close the current screen 
    CloseScreen() 
    
    ;and reopen the titlescreen 
    TitleScreen() 
    
  Else 
    MessageRequester("Error",  "Can't open a 480*640 - 16 bit screen !", 0) 
  EndIf 
  
  ;remove all the sprites And sounds from memory 
  CleanUp() 
EndProcedure 

Procedure TimeAttackScoreMod() 
;If the time has not run out print the current score 
  If Timer  < > 0 
    If StartDrawing(ScreenOutput()) 
      
      ;draw the placeholder "Score" at x 400 y 100 
      DrawText(400, 100, "Score:") 
      
      ;draw player 1's score at x 420 y 100 
      DrawText(450, 100, Str(Player1\Score)) 
      
      ;draw the placeholder "Time:" at x 400 y 120 
      DrawText(400, 120, "Time:") 
      
      ;draw the cutrrent time limit at x 420 y 120 
      DrawText(440, 120, Str(Timer)) 
      
      StopDrawing() 
    EndIf 
  EndIf 
  
  If Timer = 0 
  
  If StartDrawing(ScreenOutput()) 
      
      ;draw the placeholder "Score" at x 400 y 100 
      DrawText(400, 100, "Score:") 
      
      ;draw player 1's score at x 420 y 100 
      DrawText(420, 100, Str(Player1\Score)) 
      
      ;draw the placeholder "Time:" at x 400 y 120 
      DrawText(400, 120, "Time:") 
      
      ;draw the "Time's Up" message at x 420 y 120 
      DrawText(420, 120, "Times Up") 
      
      StopDrawing() 
    EndIf 
  EndIf 
  
EndProcedure 

Procedure Timer(x) 
Delay(x) ; Will execute every X millisecond. 
Timer - 1 
If Timer = 0 
done = 1 
EndIf 
EndProcedure 

Procedure TwoPlayerGame() 
  ;If the window was opened successfully 
  If OpenWindow(0, 0, 0, 480, 640, #PB_Window_SystemMenu, "Pong Master v0.1 - Two Player") 
    
    ; Now, open a 640*480 - 16 bits (65000 colours) screen 
    OpenWindowedScreen(WindowID(0),  0, 0, 480, 640, 0, 1, 1) 
    
    ;Load the Sprites into Memory 
    LoadSprites() 
    
    ;Load the Sound Effects into Memory 
    LoadSounds() 
    
    ;Reset The Scores 
    ResetScores() 
    
    ;Position the Sprites 
    PositionObjects() 
    
    ;Set Done to 0 
    done  = 0 
    
    ;start the game loop 
    Repeat 
      
      ;Process Window Events 
    Event = WindowEvent() 
      
      ;if the user tries to close the window then go to the title screen 
      If Event = #PB_Event_CloseWindow 
      done = 1 
      EndIf 
      
      ;Delay the game 1 millisecand 
      Delay(1) 
      
      ;Game Interface Procedures 
      CheckForPause() 
      BallBouncing() 
      MoveBall() 
      Player1Movement() 
      Player2Movement() 
      PrintScores() 
      
      ; Inverse the buffers (the back become the front (visible)... And we can do the rendering on the back) 
      
      FlipBuffers() 
      
      ;increase the loop counter by 1 
      loopcounter + 1 
    ;if the game has looped 50 times then delay for 1 second 
    If loopcounter >= dynamic_delay_set 
   Delay(1) 
   loopcounter = 0 
   EndIf  
      
    Until KeyboardPushed(#PB_Key_Escape)Or done  = 1 
    
    ;the player just won so wait a few secs so the player can see the win message 
    Delay(1000) 
    
    ;The game is finished so remove all the sprites and sounds from memory 
    CleanUp() 
    
    ;and close the window 
    CloseWindow(0) 
    
    ;close the current screen 
    CloseScreen() 
    
    ;and reopen the title screen 
    TitleScreen() 
    
  Else 
    
    ;otherwise let the user know the window couldn't be opened 
    MessageRequester("Error",  "Can't open a 480*640 - 16 bit screen !", 0) 
  EndIf 
  
  ;remove all the sprites And sounds from memory 
  CleanUp() 
EndProcedure 
;ExecutableFormat=Windows 
;Executable=C:\Projects\Pong Master - Pure BASIC\Pong Master.exe 
;EOF
1.The Thread is only executed once and then it is removed. I want the thread to continue to execute until done = 1 which occurs when the window is closed or Timer = 0 in which the game is over.

2.I know the thread no longer excists because when i close the game window i get a [ERROR] Specified Thread No Longer Excists on Line 713, even though i never told it to kill the thread anywhere in my code beforehand.

Any ideas?

Posted: Sun Feb 19, 2006 9:40 pm
by Dark Mars Software
Can someone please help me out please?