programming a proper GUI?
Author |
Message |
Geostigma
|
Posted: Wed Apr 18, 2007 10:08 pm Post subject: programming a proper GUI? |
|
|
Is there any tutorials about using and programing the GUI system properly or is that all Object oriented programming(Turing Walkthrough stuff) I want to find the best way and most efficient way of programing my GUI so I don't have to build it up in a huge mess. My main concern is "Am I building a program that uses a GUI properly" I know its a lot to read (over 200 lines) but the only thing I'm concerned about is flow and how I'm setting this up properly and suggestions to improve this code
Turing: |
%***********************************************************
% Declaration
%***********************************************************
%***********************************************************
% Files!!!!
% ---------------------------------------------
% http://www.megaupload.com/?d=O3F8NUWH -Alpha001
%***********************************************************
%Set GUI MODE
import GUI
include "test.t"
include "mat_lessions.t"
View.Set ("graphics:800;600,nobuttonbar")
%Declair variables
%******************************************************************
% Button set
%******************************************************************
var Buttion1, Buttion2, Buttion3, Buttion4 : int
var add_button, sub_button, mlt_button, div_button : int
var easy_button, normal_button, hard_button : int
var answer1, answer2, answer3 : int
%******************************************************************
% Graphics
%******************************************************************
var Startbuttion : int := Pic.FileNew ("start_button.jpg")
var Instructionbuttion : int := Pic.FileNew ("instructions_button.jpg")
var Quitbuttion : int := Pic.FileNew ("quit_button.jpg")
var add_button_graphic : int := Pic.FileNew ("Adding_button.jpg")
var sub_button_graphic : int := Pic.FileNew ("Subtraction_button.jpg")
var div_button_graphic : int := Pic.FileNew ("division_button.jpg")
var mlt_button_graphic : int := Pic.FileNew ("multiplication_button.jpg")
var easy_graphic : int := Pic.FileNew ("easy_button.jpg")
var normal_graphic : int := Pic.FileNew ("normal_button.jpg")
var hard_graphic : int := Pic.FileNew ("hard_button.jpg")
var instructions_text : int := Pic.FileNew ("instructions_text.bmp")
Pic.SetTransparentColor (instructions_text, black)
var Backround : int := Pic.FileNew ("Introscreen_001.jpg")
%***********************************************************
% Main Program
%***********************************************************
procedure guiend
GUI.Quit
quit
end guiend
procedure Instructions
var x, y, button : int
Pic.Draw (instructions_text, 100, 120, picMerge)
loop
Mouse.Where (x, y, button )
if button = 0 then
else
Pic.Draw (Backround, 0, 0, 0)
GUI.Refresh
exit
end if
end loop
end Instructions
procedure multiply_game_easy
put "RESERVED FOR FUNCTION"
end multiply_game_easy
procedure multiply_game_normal
put "RESERVED FOR FUNCTION"
end multiply_game_normal
procedure multiply_game_hard
put "RESERVED FOR FUNCTION"
end multiply_game_hard
procedure dividing_game_easy
put "RESERVED FOR FUNCTION"
end dividing_game_easy
procedure dividing_game_normal
put "RESERVED FOR FUNCTION"
end dividing_game_normal
procedure dividing_game_hard
put "RESERVED FOR FUNCTION"
end dividing_game_hard
procedure subtraction_game_easy
put "RESERVED FOR FUNCTION"
end subtraction_game_easy
procedure subtraction_game_normal
put "RESERVED FOR FUNCTION"
end subtraction_game_normal
procedure subtraction_game_hard
put "RESERVED FOR FUNCTION"
end subtraction_game_hard
procedure qanswer1
put "LALALALAL"
end qanswer1
procedure qanswer2
put " HAHHAHAHHHH"
end qanswer2
procedure qanswer3
put " MUHL:AHAGGG"
end qanswer3
procedure addition_game_easy
var temp1, temp2, temp3 : int
temp1 := 1 + 3
answer1 := GUI.CreateButton (300, 10, 0, intstr (temp1 ), qanswer1 )
answer2 := GUI.CreateButton (400, 10, 0, "5", qanswer2 )
answer3 := GUI.CreateButton (500, 10, 0, "8", qanswer3 )
end addition_game_easy
procedure addition_game_normal
put "RESERVED FOR FUNCTION"
end addition_game_normal
procedure addition_game_hard
put "RESERVED FOR FUNCTION"
end addition_game_hard
procedure dividing_levels
cls
Pic.Free (Backround )
Backround := Pic.FileNew ("Introscreen_001.jpg")
GUI.Dispose (add_button )
GUI.Dispose (sub_button )
GUI.Dispose (mlt_button )
GUI.Dispose (div_button )
easy_button := GUI.CreatePictureButton (50, 450, easy_graphic, dividing_game_easy )
normal_button := GUI.CreatePictureButton (50, 390, normal_graphic, dividing_game_normal )
hard_button := GUI.CreatePictureButton (50, 330, hard_graphic, dividing_game_hard )
Pic.Draw (Backround, 0, 0, 0)
GUI.Refresh
View.Update
end dividing_levels
procedure multiply_levels
cls
Pic.Free (Backround )
Backround := Pic.FileNew ("Introscreen_001.jpg")
GUI.Dispose (add_button )
GUI.Dispose (sub_button )
GUI.Dispose (mlt_button )
GUI.Dispose (div_button )
easy_button := GUI.CreatePictureButton (50, 450, easy_graphic, multiply_game_easy )
normal_button := GUI.CreatePictureButton (50, 390, normal_graphic, multiply_game_normal )
hard_button := GUI.CreatePictureButton (50, 330, hard_graphic, multiply_game_hard )
Pic.Draw (Backround, 0, 0, 0)
GUI.Refresh
View.Update
end multiply_levels
procedure subtracting_levels
cls
Pic.Free (Backround )
Backround := Pic.FileNew ("Introscreen_001.jpg")
GUI.Dispose (add_button )
GUI.Dispose (sub_button )
GUI.Dispose (mlt_button )
GUI.Dispose (div_button )
easy_button := GUI.CreatePictureButton (50, 450, easy_graphic, subtraction_game_easy )
normal_button := GUI.CreatePictureButton (50, 390, normal_graphic, subtraction_game_normal )
hard_button := GUI.CreatePictureButton (50, 330, hard_graphic, subtraction_game_hard )
Pic.Draw (Backround, 0, 0, 0)
GUI.Refresh
View.Update
end subtracting_levels
procedure adding_levels
cls
Pic.Free (Backround )
Backround := Pic.FileNew ("Introscreen_001.jpg")
GUI.Dispose (add_button )
GUI.Dispose (sub_button )
GUI.Dispose (mlt_button )
GUI.Dispose (div_button )
easy_button := GUI.CreatePictureButton (50, 450, easy_graphic, addition_game_easy )
normal_button := GUI.CreatePictureButton (50, 390, normal_graphic, addition_game_normal )
hard_button := GUI.CreatePictureButton (50, 330, hard_graphic, addition_game_hard )
Pic.Draw (Backround, 0, 0, 0)
GUI.Refresh
View.Update
end adding_levels
procedure Game_Start
cls
Pic.Free (Backround )
Backround := Pic.FileNew ("Introscreen_001.jpg")
GUI.Dispose (Buttion1 )
GUI.Dispose (Buttion2 )
add_button := GUI.CreatePictureButton (50, 450, add_button_graphic, adding_levels )
sub_button := GUI.CreatePictureButton (50, 390, sub_button_graphic, subtracting_levels )
mlt_button := GUI.CreatePictureButton (50, 330, mlt_button_graphic, multiply_levels )
div_button := GUI.CreatePictureButton (50, 270, div_button_graphic, dividing_levels )
Pic.Draw (Backround, 0, 0, 0)
GUI.Refresh
View.Update
end Game_Start
Pic.Draw (Backround, 0, 0, 0)
Buttion1 := GUI.CreatePictureButton (50, 450, Startbuttion, Game_Start )
Buttion2 := GUI.CreatePictureButton (50, 250, Instructionbuttion, Instructions )
Buttion3 := GUI.CreatePictureButton (50, 50, Quitbuttion, guiend )
loop
exit when GUI.ProcessEvent
end loop
|
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
rollerdude

|
Posted: Fri Apr 20, 2007 10:07 am Post subject: Re: programming a proper GUI? |
|
|
i have found a wonderful thing called a "unit" use this for your gui mess and then import, but that gets a bit tricky, and annoying... |
|
|
|
|
 |
Clayton

|
Posted: Fri Apr 20, 2007 10:13 am Post subject: RE:programming a proper GUI? |
|
|
How does it get tricky?
simply:
Turing: |
unit
module Foo
end Foo
%or
unit
class Bar
end Bar
|
Then, making sure you have the class/module in the same directory:
 |
|
|
|
|
 |
|
|