Gui
Author |
Message |
donutking
|
Posted: Thu Jan 11, 2007 10:04 pm Post subject: Gui |
|
|
Every time i use a GUI Turing annouces a fatal error. What's the problem? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Prince Pwn
|
Posted: Thu Jan 11, 2007 10:16 pm Post subject: RE:Gui |
|
|
At the top of your program, you must:
|
|
|
|
|
|
donutking
|
Posted: Thu Jan 11, 2007 10:17 pm Post subject: Re: Gui |
|
|
i did that already, the error is still there |
|
|
|
|
|
Prince Pwn
|
Posted: Thu Jan 11, 2007 10:19 pm Post subject: Re: Gui |
|
|
Post your code or give a better explanation. |
|
|
|
|
|
donutking
|
Posted: Thu Jan 11, 2007 10:22 pm Post subject: Re: Gui |
|
|
here's the code, what's wrong?
[/code]
%Variables
import GUI
setscreen ("Graphics")
setscreen ("nocursor")
var key : string (1)
var draw, draw2, draw3, draw4, yes, no, quitGame, v, w, x, y, z : int := 0
var pic : int
var btn, btnupdwn : int
proc title
cls
locate (1, 34)
put "The Ramdom Blocks Game"
put ""
end title
proc PauseProgram
put ""
put "Please press any button to continue:"
getch (key)
end PauseProgram
proc Game1
var sqr, sqr2, sqr3, sqr4, sqr5, box, box2, box3, box4, box5 : string
var mx, my, updown : int
cls
drawbox (0, 0, 75, 75, 7)
drawbox (100, 0, 175, 75, 7)
drawbox (200, 0, 275, 75, 7)
drawbox (300, 0, 375, 75, 7)
drawbox (400, 0, 475, 75, 7)
var x1, y1, x2, y2, x3, y3, x4, y4, y5, x5 : int
randint (x1, 0, 25)
randint (x2, 100, 125)
randint (x3, 200, 225)
randint (x4, 310, 335)
randint (x5, 420, 455)
y1 := 199
y2 := 210
y3 := 220
y4 := 230
y5 := 240
randint (v, 0, 255)
randint (w, 0, 255)
randint (x, 0, 255)
randint (y, 0, 255)
randint (z, 0, 255)
drawfillbox (x1, y1, x1 + 50, y1 + 50, v)
drawfillbox (x2, y2, x2 + 55, y2 + 60, w)
drawfillbox (x3, y3, x3 + 60, y3 + 70, x)
drawfillbox (x4, y4, x4 + 65, y4 + 80, y)
drawfillbox (x5, y5, x5 + 70, y5 + 90, z)
loop
if buttonmoved ("down") then
buttonwait ("down", mx, my, btn, updown)
if x1 <= mx and mx <= x1 + 50 and y1 <= my and my <= y1 + 50 then
x1 := mx
y1 := my
loop
mousewhere (mx, my, updown)
drawfillbox (mx - 10, my - 10, mx + 60, my + 60, 0)
drawfillbox (mx, my, mx + 50, my + 50, v)
exit when updown = 0
end loop
x1 := mx
y1 := my
elsif x2 <= mx and mx <= x2 + 55 and y2 <= my and my <= y2 + 60 then
x2 := mx
y2 := my
buttonwait ("down", mx, my, btn, updown)
loop
mousewhere (mx, my, updown)
drawfillbox (mx, my, mx + 55, my + 60, w)
exit when updown = 0
end loop
x2 := mx
y2 := my
elsif x3 <= mx and mx <= x3 + 60 and y3 <= my and my <= y3 + 70 then
x3 := mx
y3 := my
buttonwait ("down", mx, my, btn, updown)
loop
mousewhere (mx, my, updown)
drawfillbox (mx, my, mx + 60, my + 70, x)
exit when updown = 0
end loop
x3 := mx
y3 := my
elsif x4 <= mx and mx <= x4 + 65 and y4 <= my and my <= y4 + 80 then
x4 := mx
y4 := my
buttonwait ("down", mx, my, btn, updown)
loop
mousewhere (mx, my, updown)
drawfillbox (mx, my, mx + 65, my + 80, y)
exit when updown = 0
end loop
x4 := mx
y4 := my
elsif x5 <= mx and mx <= x5 + 70 and y5 <= my and my <= y5 + 90 then
x5 := mx
y5 := my
buttonwait ("down", mx, my, btn, updown)
loop
mousewhere (mx, my, updown)
drawfillbox (mx, my, mx + 70, my + 90, z)
exit when updown = 0
end loop
x5 := mx
y5 := my
end if
end if
end loop
end Game1
proc intro
put "This is the Moving blocks game!!!"
put "Created by the donutking!!!"
cls
end intro
proc startScreen
title
intro
pic := Pic.FileNew ("donut.bmp")
Pic.Draw (pic, 0, 0, picUnderMerge)
draw := GUI.CreateButtonFull (10, 100, 0, "Start Game", Game1, 0, '^F', false)
quitGame := GUI.CreateButtonFull (200, 100, 0, "Quit", GUI.Quit, 0, KEY_ESC, false)
loop
exit when GUI.ProcessEvent
end loop
end startScreen
proc goodbye
put "Would you like to play again?"
yes := GUI.CreateButtonFull (10, 100, 0, "Yes", intro, 0, '^F', true)
no := GUI.CreateButtonFull (200, 100, 0, "No", GUI.Quit, 0, KEY_ESC, false)
loop
exit when GUI.ProcessEvent
end loop
end goodbye
title
PauseProgram
startScreen |
|
|
|
|
|
Prince Pwn
|
Posted: Thu Jan 11, 2007 10:27 pm Post subject: Re: Gui |
|
|
In your startScreen procedure I commented out the
And it worked fine when I clicked your buttons and everything. The error might be your picture in the wrong directory, or post the exact error you get. |
|
|
|
|
|
donutking
|
Posted: Thu Jan 11, 2007 10:34 pm Post subject: Re: Gui |
|
|
the error is that fatal internal error thing, where it says that its a bug in the environment |
|
|
|
|
|
Ultrahex
|
Posted: Thu Jan 11, 2007 10:38 pm Post subject: Re: Gui |
|
|
It also works fine for me, so therefore either your turing version is differnt then ours (4.04c - or something along the lines of that).
Otherwise, I cannot help you much here... |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Clayton
|
Posted: Thu Jan 11, 2007 11:02 pm Post subject: Re: Gui |
|
|
could you please give us the exact error? If you do that it might help us a bit, as I am not getting the error either. |
|
|
|
|
|
ericfourfour
|
Posted: Fri Jan 12, 2007 12:22 am Post subject: RE:Gui |
|
|
Post what the error says. I'm thinking it has something to do with accessing memory that does not exist. |
|
|
|
|
|
[Gandalf]
|
Posted: Fri Jan 12, 2007 6:15 pm Post subject: RE:Gui |
|
|
Sounds like it's most likely something to do with your version of Turing rather than the code itself. The fatal error message, as you said, says that it's a problem with the environment, which would be the Turing IDE. |
|
|
|
|
|
CodeMonkey2000
|
Posted: Fri Jan 12, 2007 10:27 pm Post subject: Re: Gui |
|
|
Is it just me or does turing act funny? In the quiz i made for grade 9 programming last year,and i imported gui, the program sometimes worked properly and sometimes does something wrong. I noticed that with the pic module too. I encountered a problem where turing did something funny a while ago, turing kept displaying the worng picture.I ran the program numerous times and it still happened. When I restart my comp everything was back to normal. Is there something wrong with how I implement my code or is it just turing? |
|
|
|
|
|
ericfourfour
|
Posted: Sat Jan 13, 2007 3:54 am Post subject: RE:Gui |
|
|
Turing's GUI, when used properly, should not have any errors. Neither should the Pic module. |
|
|
|
|
|
|
|