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

Username:   Password: 
 RegisterRegister   
 GUI help required...this isnt covered in the tutorial...
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
void




PostPosted: Sun Apr 06, 2003 1:34 pm   Post subject: GUI help required...this isnt covered in the tutorial...

I know there is already a GraphicUserInterface tutorial...but i cant how to locate menu Sad ...so here is the one that i made...it isnt very advanced Embarassed ...the code first opens the window in full **famous players voice** for maximum gaming experience......i'm not sure how to locate the menu....i want to have the whole screen black but a 400*680 screen in which the menu will be displayed and the game will be played within....
im planning on having the game like this:
-a thick frame of black with sparkling "stars"
Wink
-a 400*680 "playing screen"
-the menu is used to save/load/quit and start a new game
- the title is displayed above the menu in the frame
- the score is displayed somewhere beside the playing feild(in the frame) along with the Level and the players name current sound track.....i have most of that working...but stupid me Evil or Very Mad ...i created the score/level and black frame seperate of the game and GUI and now when i try to merge it...the frame is inside the GUI..i dont want that....is there anyway that i can "locate" the GUI?
Confused sorry if i wrote too much and confused you guys...coz im REALLY confused.....my screen is black frame and game but the GUI is apperaing above the name and cutting off part of it...im just gonna paste the code for the GUI...if you can manage to locate it...i would be forever greatfull...seeing as this is my exam Shocked thanx in advance Very Happy
code:

%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%   Collapse    %%%%%
%%%%%  By:Dushy T   %%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%

%%Importing GUI Functions Library%%
import GUI in "%oot/lib/GUI"

%%Declaring GUI Variables%%
var menu : int
var item : array 1 .. 4 of int
var name : array 1 .. 4 of string := init ("New Game", "Save", "Load",
    "Quit")

%%Setting Screen Size%%
var w : int := Window.Open ("fullscreen")

%%Declaring I/O Variables%%
var stremin, stremout : int
var save : string := "save.txt"

%%Declaring Game Variables
var level : int := 7
var count : int

%%Game Procedure
procedure Game
    cls
    put "This is an empty shell.....insert game code here"
end Game

%%GUI Procedure (excluding Game)%%
procedure Save
    count := 1
    open : stremin, save, write
    write : stremin, level
    close : stremin
    put ""
    put ""
    put ""
    put "Saving" ..
    for a : 1 .. 10
        put repeat (".", count) ..
        delay (100)
    end for
    put "Complete"
end Save
procedure Load
    open : stremout, save, read
    read : stremout, level
    close : stremout
    put "Loading Level ", level
    for a : 1 .. 10
        put repeat (".", count) ..
        delay (100)
    end for
    put "Complete"
    put "Generating"
    delay (1000)
    Game
end Load
procedure Quit
    GUI.Quit
end Quit

%%Drawing GUI%%
menu := GUI.CreateMenu ("Menu")
item (1) := GUI.CreateMenuItem (name (1), Game)
item (2) := GUI.CreateMenuItem (name (2), Save)
item (3) := GUI.CreateMenuItem (name (3), Load)
item (4) := GUI.CreateMenuItem (name (4), Quit)
loop
    exit when GUI.ProcessEvent
end loop
Window.Close (w)

thats it...i added the extra crap...u can delete that when you copy it into your editor
why cant turing be as easy as HTML........i mean turing seriously is too tempermental....caps has to be right...spacing has to be right..... Mad
also...can some explain how to do the color recognition so that if someone clicks on a blue square...it wont disappear unless there are three touching blue squares
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sun Apr 06, 2003 2:12 pm   Post subject: (No subject)

if you mean putting menu somewhere other then on top, then you have to write your own custom GUI. Menu is *suppost* to be on top so Tom never though of giving an option to move it. Maybe you can modify GUI module for allow you to do that?

as for color recognition stuff...

you have to search through your array with a spread algorythm. Once clicked on a square, the procedure checks the 4 squares around it for the same color. In your case, if its the same (2 same colors touching each other), that block gets marked as being in this group and procedure repeats, originating from that square. After the procedure returns to original square, you just count how many blocks were marked and you get the number of samecolor blocks touching each other in a group.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
void




PostPosted: Sun Apr 06, 2003 3:23 pm   Post subject: i bow humbly before you

thank you sooooooooo much...you dont realize how much easier you have just made my life!!!!! Surprised you guys are fast...i just posted the message like 2 hours ago....normaly my replies take days on other forums (not on winoot...there arent any other forums Wink ) i did manage to change the coding in the GUI module and now the menu is a floating menu Very Happy ...one of my buddies had a question..he's making one of those games where you gotta protect your city from enemy missiles...but he wants ta make it like the really old ones so that it wont require much effore...unfortunately..he's a complete dumb@$$ when it comes to programming (the class is learning graphics and this kid doesnt even understand simple 2d arrays or read/write to files)...any suggestions for his little venture....i've tried to help him...and now hes got the bombs working:
code:

setscreen ("nocursor")
var x, y, button : int
drawfillbox (maxx, maxy, - 5, - 5, 256)
process crosshair
    loop
        Mouse.Where (x, y, button)
        drawline (x, y, x, y + 20, 10)
        drawline (x - 10, y + 10, x + 10, y + 10, 10)
        delay (10)
        drawline (x, y, x, y + 20, 256)
        drawline (x - 10, y + 10, x + 10, y + 10, 256)
    end loop
end crosshair
process bomb
    loop
        if button = 1 then
            const x1 := x
            const y1 := y
            for a : 1 .. 30
                drawfilloval (x1, y1 + 10, a, a, red)
                delay (10)
            end for
            delay (100)
            drawfilloval (x1, y1 + 10, 30, 30, black)
        end if
    end loop
end bomb
fork crosshair
fork bomb

(i wrote all of that for him...he kinda just sat there and nodded his head Razz) but yea...do u know how he would go abouts making the lines come down and then the clicking and the destroying and then the chain reaction where if one blown up missiles is within a ceratin radius of another missile..then that one blows up too....yeha...he thanks you in advance...oh yea..is there any way that i can redeclare variable..llike its being declared in a loop after two numbers have been retreived so that i can create a 2d array ...im sorry if im asking too many questions...i know u pplz prolly have betta things ta do than help me...but i hafta do well on this.. Very Happy
Tony




PostPosted: Sun Apr 06, 2003 5:08 pm   Post subject: (No subject)

what? there's another forum? Confused

anyway, I dont understand what you mean by drawing lines, you'd have to elaborate on that.

as for chain reactions, you can use circle colision detection (we got that in tutorials).

I'm not sure what you mean by redeclearing variables ether. If its just a simple variable, you can declear it outside the loop and just change value. If you mean array, you'd have to declear it as flexable array, but someone else would have to give you syntax for that.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
nate




PostPosted: Sun Apr 06, 2003 6:20 pm   Post subject: Crosshair with mouse

FOR SOME REASON YOUR CODE STIll PRODUCES THE CURSOR?
EVEN WITH View.Set ("nocursor")

CAN U MAKE IT SO THERE IS NO CURSOR?

Also is there a code that restricts where the mouse can move. So you can make it not go off the page?

PLEASE RESPOND
-NAte
void




PostPosted: Sun Apr 06, 2003 7:00 pm   Post subject: Cursor No Go

the view.set ("nocursor") actually only makes the flashing cursor disapper No matter what you do the actual pointer will never disappear off the page...but if your crosshair is like mine and quite some distance from the pointer (cursor...same shizzle) then it will not be a problem....as for the mouse restriction....not as far as i kno...but you'd have to ask one of the hacker gods to be sure....you can always restrict the crosshair for example:
var x,y,button:int
loop
Mouse.Where (x,y,button)
if x>(whatever limit you set on the x value) then
put "OOPS! Your crosshair is off the page"
end if
(repeat the same thing for the y co ordinate)

also..if you want to make is so that even if the mouse is greater than a certain x/y value the crosshair (or whatever other pointer you use) is still within your limits i suggest creating a second set of x and y variable (x1,y1) and constantly makeing them equal to x and y (x1:=x, y1:=y) and then use the same statement that i used above but instead of the stupid remark make x1:=whatever you want as your max x value and so on.... i hope this helps.... Wink any better suggestions will most likely be posted
Tony




PostPosted: Sun Apr 06, 2003 8:19 pm   Post subject: (No subject)

I once came across an interesting program writen in Visual Basic that controls your mouse... quite interesting.

but to do so, you need to access window's APIs, which you cant do in turing Sad

so in other words, mouse pointer always stays and can go anywhere on the screen.

But void has a good idea with vertual mouse pointer.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
void




PostPosted: Mon Apr 07, 2003 3:45 pm   Post subject: LINE!!!

okay..im completely out of ideas...i need someone to PLEASE give me a code that makes a lines randomly appear (more than one simultaneously) from the sky...and gradually head down towards the bottom of the screen....Very Happy its for the program where you protect your city from bombarding missiles by bombing them....thanks a bunch :>
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  [ 8 Posts ]
Jump to:   


Style:  
Search: