Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Error stopping a process also code help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Copler




PostPosted: Thu Nov 20, 2003 8:58 pm   Post subject: Error stopping a process also code help

I need help with my code:

For one thing I cant actually stop the proc Star_Feild
(a little program made to simulate travel through space)

When I try navigating when I click New the StarFeild is still going
and i cant figure out how to stop/pause the proc can I have some help please? Mad

PS Not Finished Yet

[code]

/* 21st Century Sports Trivia

By Matthew Harford

*/


var guimain : int := Pic.FileNew ("Trivia_1024x768_GUI.jpg")
var win := Window.Open ("offscreenonly,nobuttonbar,noecho,graphics:800;600"
+ ",position:center;truemiddle")
Pic.ScreenLoad ("Trivia_1024x768_GUI.jpg", 0, 0, picCopy)
%Variable for the Mouse

var Mouse_Pos_X, %Mouse Posistion X Pixels
Mouse_Pos_Y, %Mouse Posistion Y Pixels
buttonnumber, %Which button Right, Left
Mouse_Button_UpDown, %Weather The button is up or down
Mouse_Buttons : int %How many buttons the mouse has

%Variables for use in GUI Topic Bar

var Topic_Name, Topic_NameR : string %Varibles for what will show in the Topic Header
var New : boolean := false
var Run : boolean := false
var Credits : flexible array 1 .. 0 of string
var Trivia_Credits : int

%Variables for the file names
var Topic_Baseball, %For the Baseball Data File
Topic_Basketball, %For the Basketball Data File
Topic_Football, %For the Football Data File
Topic_Hockey : int %For the Hockey Data File

var ifexited : int

%Variables for Basic Information

var Player_Name : string (8) %The Players Name
var Answers_Right, Answers_Wrong : int := 0 %The Variables for the Players Scores
var Answers_Averg : real %The variable for the players playing average

const Guesses : int := 3 %A constant variable for how many guesses there are
var Guesses_Left : int %A variable for how many gueses aer left
:= Guesses

var Question, %The variable to collect and display the question

Answer_A, %The variable to collect and display the Answer A
Answer_B, %The variable to collect and display the Answer B
Answer_C, %The variable to collect and display the Answer C
Answer_D, %The variable to collect and display the Answer D
Answer_R, %The variable to collect and compare the Answer
Answer_Write : array 1 .. 8 of string

const nomofstar : int := 900
const Screen_Center_X : int := maxx div 2
const Screen_Center_Y : int := maxy div 2

var Star_X : array 1 .. nomofstar of int
var Star_Y : array 1 .. nomofstar of int
var Star_Z : array 1 .. nomofstar of int

var Star_X_Draw : array 1 .. nomofstar of int
var Star_Y_Draw : array 1 .. nomofstar of int

var Topic_Choice := Rand.Int (1, 1) %For the holding of what topic the user selects

var Star_SC : int

%Variables for the fonts used
var Font_Splash : int :=
Font.New ("Agency FB:30") %Font for the Topic Header
var Font_Menu : int :=
Font.New ("Agency FB:30") %Font for the Menu Butons
var Font_Quit : int :=
Font.New ("Ariel:20") %Font for the exit warning
var Font_Topic : int :=
Font.New ("Agency FB:30") %Font for the Topic Header
var Font_Question : int :=
Font.New ("Ariel:15") %Font for the Question Header
var Font_Answer : int :=
Font.New ("Times New Roman:20") %Font For the Answer selection and input

function center (text : string, y, Color : int) : string
Font.Draw (text, (maxx div 2) - (Font.Width (text, Font_Topic) div 2), y, Font_Topic, Color)
locate (1, 1)
result ""
end center


open : Trivia_Credits, "Credits.c", get

loop

exit when eof (Trivia_Credits)

new Credits, upper (Credits) + 1
get : Trivia_Credits, Credits (upper (Credits)) : *
end loop

close : Trivia_Credits

/*Processes/Functions/Procedures/etc*/
proc Load_Rand_Topic
if Topic_Choice = 1 then
Topic_Name := "Basketball"
open : Topic_Basketball, "Basketball.Mc", get
for i : 1 .. 4
get : Topic_Basketball, Question (i) : *
get : Topic_Basketball, Answer_A (i) : *
get : Topic_Basketball, Answer_B (i) : *
get : Topic_Basketball, Answer_C (i) : *
get : Topic_Basketball, Answer_D (i) : *
get : Topic_Basketball, Answer_R (i) : *
end for
close : Topic_Basketball
open : Topic_Basketball, "Basketball.Fill", get
for i : 5 .. 8
get : Topic_Basketball, Question (i) : *
get : Topic_Basketball, Answer_R (i) : *
end for
close : Topic_Basketball
elsif Topic_Choice = 2 then
Topic_Name := "Baseball"
open : Topic_Baseball, "Baseball.Mc", get
for i : 1 .. 4
get : Topic_Baseball, Question (i) : *
get : Topic_Baseball, Answer_A (i) : *
get : Topic_Baseball, Answer_B (i) : *
get : Topic_Baseball, Answer_C (i) : *
get : Topic_Baseball, Answer_D (i) : *
get : Topic_Baseball, Answer_R (i) : *
end for
close : Topic_Baseball
open : Topic_Baseball, "Baseball.Fill", get
for i : 5 .. 8
get : Topic_Baseball, Question (i) : *
get : Topic_Baseball, Answer_R (i) : *
end for
close : Topic_Baseball
elsif Topic_Choice = 3 then
Topic_Name := "Football"
open : Topic_Football, "Football.Mc", get
for i : 1 .. 4
get : Topic_Football, Question (i) : *
get : Topic_Football, Answer_A (i) : *
get : Topic_Football, Answer_B (i) : *
get : Topic_Football, Answer_C (i) : *
get : Topic_Football, Answer_D (i) : *
get : Topic_Football, Answer_R (i) : *
end for
close : Topic_Football
open : Topic_Football, "Football.Fill", get
for i : 5 .. 8
get : Topic_Football, Question (i) : *
get : Topic_Football, Answer_R (i) : *
end for
close : Topic_Football
elsif Topic_Choice = 4 then
Topic_Name := "Hockey"
open : Topic_Hockey, "Hockey.Mc", get
for i : 1 .. 4
get : Topic_Hockey, Question (i) : *
get : Topic_Hockey, Answer_A (i) : *
get : Topic_Hockey, Answer_B (i) : *
get : Topic_Hockey, Answer_C (i) : *
get : Topic_Hockey, Answer_D (i) : *
get : Topic_Hockey, Answer_R (i) : *
end for
close : Topic_Hockey
open : Topic_Hockey, "Hockey.Fill", get
for i : 5 .. 8
get : Topic_Hockey, Question (i) : *
get : Topic_Hockey, Answer_R (i) : *
end for
close : Topic_Hockey
end if
end Load_Rand_Topic


proc Star
for i : 1 .. nomofstar
Star_X (i) := Rand.Int (-500, 500)
Star_Y (i) := Rand.Int (-500, 500)
Star_Z (i) := Rand.Int (100, 1000)
end for
end Star

proc Star_Col
for i : 1 .. maxcolor
RGB.SetColor (255 - i, i, i, i)
end for
end Star_Col

proc Star_Draw
for i : 1 .. nomofstar
Star_X_Draw (i) := round (Star_X (i) / Star_Z (i) * 100 + (maxx div 2))
Star_Y_Draw (i) := round (Star_Y (i) / Star_Z (i) * 100 + (maxy div 2))
end for
end Star_Draw

proc Star_Feild (Run : boolean)
Star
Star_Draw
Star_Col
var b : int
if Run = true then
loop
exit when Run = false
colorback (black)
cls
for t : 1 .. upper (Credits)
for a : -190 .. 190 by 6
for i : 1 .. nomofstar
drawdot (Star_X_Draw (i), Star_Y_Draw (i), black)
Star_Z (i) -= 5
if Star_X_Draw (i) > maxx and Star_Y_Draw (i) > maxy or Star_X_Draw (i) < 1 and Star_Y_Draw (i) < 1 then
Star_X_Draw (i) := Screen_Center_X
Star_Y_Draw (i) := Screen_Center_Y
Star_Z (i) := Rand.Int (100, 1000)
elsif Star_Z (i) <= 0 then
Star_Z (i) := Rand.Int (100, 1000)
end if
Star_X_Draw (i) := round (Star_X (i) / Star_Z (i) * 100 + (maxx div 2))
Star_Y_Draw (i) := round (Star_Y (i) / Star_Z (i) * 100 + (maxy div 2))
b := 255 - round ((Star_Z (i) * (255. / 1000.)))
drawdot (Star_X_Draw (i), Star_Y_Draw (i), b)
end for
if Run = true then
Font.Draw ("Welcome to 21st Century Sports Trivia", 418, maxy - 36, Font_Question, b)
Font.Draw ("(Click One of the buttons to continue)", 418, maxy - 60, Font_Question, b)
Font.Draw (Topic_Name, ((385 div 2) - (Font.Width (Topic_Name, Font_Topic) div 2)) + 8, maxy - 57, Font_Topic, b)
put center (Credits (t), maxy div 2 + a, b)

View.Update

Font.Draw ("Welcome to 21st Century Sports Trivia", 418, maxy - 36, Font_Question, black)
Font.Draw ("(Click One of the buttons to continue)", 418, maxy - 60, Font_Question, black)
Font.Draw (Topic_Name, ((385 div 2) - (Font.Width (Topic_Name, Font_Topic) div 2)) + 8, maxy - 57, Font_Topic, black)
put center (Credits (t), maxy div 2 + a, black)
end if
end for
end for

end loop
else
View.ClipOff
return
end if
end Star_Feild

process Selection_System
loop
Mouse.ButtonWait ("downup", Mouse_Pos_X, Mouse_Pos_Y, Mouse_Buttons, Mouse_Button_UpDown)

if Mouse_Pos_X >= 0 and Mouse_Pos_X <= 85 then
if Mouse_Pos_Y >= 100 and Mouse_Pos_Y <= 145 then
Window.Close (win)
elsif Mouse_Pos_Y >= 165 and Mouse_Pos_Y <= 210 then

elsif Mouse_Pos_Y >= 230 and Mouse_Pos_Y <= 270 then

elsif Mouse_Pos_Y >= 295 and Mouse_Pos_Y <= 330 then
Font.Draw ("Basketball", 225 - (Font.Width ("Basketball", Font_Topic) div 2), 60, Font_Topic, white)
Font.Draw ("Baseball", 575 - (Font.Width ("Baseball", Font_Topic) div 2), 60, Font_Topic, white)
Font.Draw ("Football", 225 - (Font.Width ("Football", Font_Topic) div 2), 10, Font_Topic, white)
Font.Draw ("Hockey", 575 - (Font.Width ("Hockey", Font_Topic) div 2), 10, Font_Topic, white)

Mouse.ButtonWait ("downup", Mouse_Pos_X, Mouse_Pos_Y, Mouse_Buttons, Mouse_Button_UpDown)

if Mouse_Pos_X >= 350 and Mouse_Pos_X <= 388 then %Buttons A and C
if Mouse_Pos_Y >= 50 and Mouse_Pos_Y <= 90 then
Topic_Choice := 1
return
elsif Mouse_Pos_Y >= 5 and Mouse_Pos_Y <= 45 then
Topic_Choice := 3
return
end if
elsif Mouse_Pos_X >= 410 and Mouse_Pos_X <= 75 then %Buttons B and D
if Mouse_Pos_Y >= 50 and Mouse_Pos_Y <= 90 then
Topic_Choice := 2
return
elsif Mouse_Pos_Y >= 5 and Mouse_Pos_Y <= 45 then
Topic_Choice := 4
return
end if
end if

Font.Draw (Topic_NameR, ((385 div 2) - (Font.Width (Topic_NameR,
Font_Topic) div 2)) + 8, maxy - 57, Font_Topic, white)

elsif Mouse_Pos_Y >= 445 and Mouse_Pos_Y <= 485 then
cls
Pic.ScreenLoad ("Trivia_1024x768_GUI.jpg", 0, 0, picCopy)

for i : 1 .. 8
Font.Draw (Topic_Name, ((385 div 2) - (Font.Width (Topic_Name,
Font_Topic) div 2)) + 8, maxy - 57, Font_Topic, white)
Pic.ScreenLoad
("Trivia_1024x768_GUI.jpg", 0, 0,
picCopy)

if length (Question (i)) >= 0 and length (Question (i)) <= 40 then
Font.Draw (Question (i) (1 .. *), 418, maxy - 36, Font_Question, white)
else
Font.Draw (Question (i) (1 .. 40), 418, maxy - 36, Font_Question, white)
if Question (i) (41) = " " then
Font.Draw (Question (i) (42 .. *), 418, maxy - 58, Font_Question, white)
else
Font.Draw (Question (i) (41 .. *), 418, maxy - 58, Font_Question, white)
end if
end if
if i >= 1 and i <= 4 then
Font.Draw (Answer_A (i), 225 - (Font.Width (Answer_A (i), Font_Topic) div 2), 60, Font_Topic, white)
Font.Draw (Answer_B (i), 575 - (Font.Width (Answer_B (i), Font_Topic) div 2), 60, Font_Topic, white)
Font.Draw (Answer_C (i), 225 - (Font.Width (Answer_C (i), Font_Topic) div 2), 10, Font_Topic, white)
Font.Draw (Answer_D (i), 575 - (Font.Width (Answer_D (i), Font_Topic) div 2), 10, Font_Topic, white)
loop
if Guesses_Left = 0 then

elsif Guesses_Left > 0 then
Mouse.ButtonWait ("downup", Mouse_Pos_X, Mouse_Pos_Y, Mouse_Buttons, Mouse_Button_UpDown)
if Mouse_Pos_X >= 350 and Mouse_Pos_X <= 388 then %Buttons A and C
if Mouse_Pos_Y >= 50 and Mouse_Pos_Y <= 90 then
if Answer_R (i) = Answer_A (i) then
Answers_Right += 1

else
Answers_Wrong += 1
Guesses_Left -= 1
end if
elsif Mouse_Pos_Y >= 5 and Mouse_Pos_Y <= 45 then
if Answer_R (i) = Answer_C (i) then
Answers_Right += 1
else
Answers_Wrong += 1
Guesses_Left -= 1
end if
end if
elsif Mouse_Pos_X >= 410 and Mouse_Pos_X <= 75 then %Buttons B and D
if Mouse_Pos_Y >= 50 and Mouse_Pos_Y <= 90 then
if Answer_R (i) = Answer_B (i) then
Answers_Right += 1
else
Answers_Wrong += 1
Guesses_Left -= 1
end if

elsif Mouse_Pos_Y >= 5 and Mouse_Pos_Y <= 45 then
if Answer_R (i) = Answer_D (i) then
Answers_Right += 1
else
Answers_Wrong += 1
Guesses_Left -= 1
end if
end if
end if

end if
end loop
else
end if
end for
end if
end if
end loop
end Selection_System


/*Load Trivia Screen========================================================*/
proc Load_Trivia_Screen

/*The below procedures sets the clipping region to the rectangle specified
by (x1, y1) -(x2, y2). If a clipping region already exist, it is replaced
by the specified rectangle. A clipping region is the region in which the
output will appear. If the rectangle is specified as the clipping region,
any drawing done outside the rectangle will not appear.*/

View.ClipSet (112, 115, 685, 485)
View.ClipAdd (415, 530, 785, 585)
View.ClipAdd (015, 535, 380, 575)
View.ClipAdd (100, 000, 695, 095)

/*The below procedure activates (starts the concurrent execution of) a
process declaration. If the process has parameters, a parenthesized list
of expressions (expns) must follow the process' name (processId). */

Load_Rand_Topic
Star_Feild (true)

/* The below procedure gets information about a mouse event and removes it
from the queue.*/

Mouse.ButtonWait ("downup", Mouse_Pos_X, Mouse_Pos_Y, Mouse_Buttons
, Mouse_Button_UpDown)




end Load_Trivia_Screen
/*==========================================================================*/

/*Load Splash Screen========================================================*/
proc Load_Splash_Screen

/*The below procedures sets the clipping region to the rectangle specified
by (x1, y1) -(x2, y2). If a clipping region already exist, it is replaced
by the specified rectangle. A clipping region is the region in which the
output will appear. If the rectangle is specified as the clipping region,
any drawing done outside the rectangle will not appear.*/

View.ClipSet (112, 115, 685, 485)

/*The Below procedure displays a picture from a file straight to the
screen*/

Pic.ScreenLoad ("Trivia_Splash.jpg", 112, 120, picCopy)

/*The below procedure updates a Run window from an offscreen bitmap. It is
used with the command View.Set( "offscreenonly" ) which prevents the Run
window from being updated until the View.Update command is given.*/

View.Update

%The below procedure gets information about a mouse event and removes it
%from the queue.

Mouse.ButtonWait ("downup", Mouse_Pos_X, Mouse_Pos_Y, Mouse_Buttons
, Mouse_Button_UpDown)

%The below procedure is used to change the color upon which text appears

colorback (red)

%The below procedure is used to blank the output window. The cursor is set
%to the top left (to row 1, column 1)

cls

/*The below procedure turns off clipping. This means that any drawing
commands can appear on the entire drawing surface*/

View.ClipOff

end Load_Splash_Screen
/*==========================================================================*/

/*Debuger : Developer Uses =================================================*/
proc Debug
var x, y, button : int

loop
mousewhere (x, y, button)
locate (1, 1)
put x, ":", y
View.Update
end loop
end Debug
/*==========================================================================*/


/*================ALGORITHEM FOR 20TH CENTURY SPORTS TRIVIA=================*/

/*Step One:

I Want to call the game and load the Splash Screen
* Waiting for the mouse to click before running the Game GUI*/

Load_Splash_Screen %Calls the Load_Splash_Screen Procedure
%Debug
/*Step Two:

I Want to call the Game GUI:

* Load the Buttons Procedures Which will be in a constant loop throughout the
Game so that they can play the game while being able to navigate the menus

* The Loop must be called as a process allowing the procedure to run
similtaniously with the program. Depending on which mode you are in and
having the program specify those conditions

eg. When I am in the Main Menu and I click Exit it will just Exit and when I
am in a game it will ask me to click Exit to confirm it.

*

*/

fork Selection_System %Calls the Navigational Game System

Load_Trivia_Screen %Calls the Load_Trivia_Screen Procedure
[/code]
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: