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

Username:   Password: 
 RegisterRegister   
 Error with GUI.GetEventWidgetID when dealing with Canvas
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
GrandAvalon




PostPosted: Sat Jan 10, 2004 8:52 pm   Post subject: Error with GUI.GetEventWidgetID when dealing with Canvas

I am trying to create a card game where you can click and drag a card (multiple full canvases) and move it around the screen. However, GUI.GetEventWidgetID doesn't seem to get along with the full canvas (Error: "Reference through nil pointer").... Sad

The following code was used to test GUI.GetEventWidgetID.

code:

import GUI in "%oot/lib/gui"
var canvas : int

procedure nothing (x, y : int)

end nothing

procedure test (x, y : int)
    var a : int
    a := GUI.GetEventWidgetID
end test

canvas := GUI.CreateCanvasFull (10, 10, 30, 40, 1, test, nothing, nothing)

loop
    exit when GUI.ProcessEvent
end loop
Sponsor
Sponsor
Sponsor
sponsor
Dan




PostPosted: Sat Jan 10, 2004 9:14 pm   Post subject: (No subject)

needs to be:

import GUI in "%oot/lib/GUI"

need cpas in the GUI, well at least it is that way on my comp
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
GrandAvalon




PostPosted: Sat Jan 10, 2004 9:23 pm   Post subject: (No subject)

That is not the problem.
Andy




PostPosted: Sat Jan 10, 2004 9:26 pm   Post subject: (No subject)

GUI can be very messy, i suggest making ur own... i remember last yr when i had a problem with the gui textbox, i was making a chatprogram, but whenever someone pressed a key with the gui textbox on the screen the program would crash... i emailed tom west and he told me to declare the textfield before the textbox... y dont u email him and ask about it?
GrandAvalon




PostPosted: Sat Jan 10, 2004 9:31 pm   Post subject: (No subject)

How long did it took him to reply?
Becuase I got only around a week to finish this program (its part of my school project).

So this can be classified as urgent
Dan




PostPosted: Sat Jan 10, 2004 9:48 pm   Post subject: (No subject)

pfff, tom? he may never reply.

sory, i did not read your question right, why do you need to use the get id thing?

just have a diffrent procedure for every canves and do somting like this:

code:

import GUI in "%oot/lib/GUI"
var canvas : int
var a : int := 0
procedure nothing (x, y : int)

end nothing

procedure test (x, y : int)
    var y1 : int := 0;
    var x1 : int := 0;
    var button : int := 0

    loop
        Mouse.Where (x1, y1, button)
        if button = 1 then
            GUI.SetPositionAndSize (canvas, 10 + (x1-30), 10 + (y1-40), 30, 40)
        end if
    end loop
end test

canvas := GUI.CreateCanvasFull (10, 10, 30, 40, 1, test, nothing, nothing)

loop
    exit when GUI.ProcessEvent
end loop


also this could be done esaser with out the GUI by making your cards in to jpg files loading them and then using the pic comands to move them.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
GrandAvalon




PostPosted: Sat Jan 10, 2004 10:30 pm   Post subject: (No subject)

Each deck has 52 cards. I will be doomed if I create a different procedure for each card, not to mention I have though about allowing the user to choose number of decks they want to use... (in casinos they usually have more than 1 deck so people cannot keep track of cards)
Tony




PostPosted: Sat Jan 10, 2004 10:36 pm   Post subject: (No subject)

gotta use arrays Rolling Eyes you can use arrays to dynamically create card buttons and such. And you can link it all back to a single procedure as long as the card number is passed to it as an argument.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
Dan




PostPosted: Sat Jan 10, 2004 10:39 pm   Post subject: (No subject)

also you could make the drawing in turing, use pic comans to truing it in to a pichutre then move it that way
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
GrandAvalon




PostPosted: Sun Jan 11, 2004 3:31 pm   Post subject: (No subject)

tony wrote:
gotta use arrays Rolling Eyes you can use arrays to dynamically create card buttons and such. And you can link it all back to a single procedure as long as the card number is passed to it as an argument.


but when you CLICK on the card, that single procedure woouldn't know who called it unless I have the GUI.GetEventWidgetID crashed-proof.

Of cause I can go through all the IDs on the array and check the X,Y coordinates and the bounds, but that will be both slow, ugly, and annoying
Dan




PostPosted: Sun Jan 11, 2004 11:39 pm   Post subject: (No subject)

i still dont get why you HAVE to uses GUI.GetEventWidgetID? in the code i posted you just need a difrent procedure for each canvas...
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
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  [ 11 Posts ]
Jump to:   


Style:  
Search: