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

Username:   Password: 
 RegisterRegister   
 Keyboard or mouse
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TheZsterBunny




PostPosted: Fri Mar 19, 2004 9:51 am   Post subject: Keyboard or mouse

I know that there is a tutorial for this in the turing manual, but it didn't really answer my question.

The user must make a selection in this game. They can either enter a number in one window or click in another one. How could I do something like this? (even better if it puts the number in the screen where you could type if you clicked)

On a different note, how are commands different in a text window?

-bunny
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Fri Mar 19, 2004 10:40 am   Post subject: (No subject)

So...let me clarify.

You have 2 windows open:
1 is a keyboard operated window, the other is a mouse operated window.

Well, to switch between windows you'd have to have some fany Window. operations going on.
Eg.
Window.Select
Window.SetActive
etc

F10 to find out more.
You'd need IDs for each window:

var win1, win2 : int

so that you can distinguish:

if Window.GetActive = win1 and mouseButton > 0 then
...

As I said, fancy win maneuvers.
It's possibly doable, dual input windows, should be fun.

On the other hand. Text windows...are you talking about

setscreen("text")

?

Because if you are, then the commands are the same, just that you cannot use graphics of any sort (i.e. no GUI, no colour/colourback commands, no locates, no Draw commands).

So, text windows are only really useful for the programmer themself, so as to analyse large amounts of output.
Eg. You make a sorting procedure. You run it on a 1000-element test list. You find that all the output scrolls off the window before you can check it.
So you change to text mode, and can scroll around it nicely.
NB: you can do this:
setscreen ("text;max;max")
TheZsterBunny




PostPosted: Fri Mar 19, 2004 11:06 am   Post subject: (No subject)

I've been Window.SetActive for a while, and have been having no trouble with it. I only wish to know how i can get either of the inputs

using the word either makes me wonder, can I use OR for this, and how would I.

There are three windows.

map - the map of the countries
stat - the player and ownership statistics
text - the text output for the game

There are still many bugs and some features have not been implimented yet (save, move troops)

This is still a beta - I hope to release the finished product by 6 this evening (7 hours from now)
TheZsterBunny




PostPosted: Sat Mar 20, 2004 9:15 am   Post subject: (No subject)

So I've been working on this for the last couple of days, and have finally narrowed down what I was looking for

If at anytime during this procedure, the current window becomes inactive, quit.

Sounds easy, but these procedures include get statements and mousewhere.

*sigh*

any help would be appreciated
McKenzie




PostPosted: Sat Mar 20, 2004 10:31 am   Post subject: (No subject)

seems that you are making it harder than it has to be, try something like:
code:
function kb_or_mouse : int
    var mx, my, mb : int := 0
    var country : int := 0
    var ch : string (1) := " "
    loop
        if hasch then
            getch (ch)
            if strintok (ch) then
                result strint (ch)
            end if
        end if
        mousewhere (mx, my, mb)
        if mb > 0 then
            result mx % you'll have to fix this
        end if
    end loop
end kb_or_mouse
TheZsterBunny




PostPosted: Sat Mar 20, 2004 3:37 pm   Post subject: (No subject)

Thanks Mr.M, but how would getch work for either 1 or 2 digit numbers?

-bunny
jonos




PostPosted: Sat Mar 20, 2004 5:24 pm   Post subject: (No subject)

getch can't do two digit numbers unless you did it like:

code:

var ch : string (1)
var sent : string := ""
for i : 1..2
     getch(ch)
     sent := sent + ch
end for


or

code:

var ch : string (1)
var sent : string := ""
loop
     exit when length(sent) = 2
     getch(ch)
     sent := sent + ch
end loop


those should work , i haven't tested them though.
the_short1




PostPosted: Sat Mar 20, 2004 6:22 pm   Post subject: (No subject)

nice nice start... i will be waiting for this game to finish.... i LOVE risk... also... then ppl can play it over MSN and just send each other cords.... ill have u a match...

one thing.... maybe size map down a notch so all windows can fit on 800 x 600 res without being moved

taht would rock...

if you need a good program to size down pictures keeping 100% of original quality,,, use irfanview.. FREE... and under 1MB... Yea... its WICKED

get it from http://www.irfanview.com
or....
get my download manager (search the short 1 to find it)

not meaning to plug here... this is intended for bunny... but im too lazy to PM



EDIT: Cervantes.... yea... paint sucks tho..
its hard to crop acurately (exactly to the pixel) and the resize dont do realy good quality, cervantes... try out irfanview for a week... ull love it..
(if u use it for all it is... (slideshows, resizing, scanning, editing)+more)
TRust me... it rocks.. and its under 1MEG!
Cervantes




PostPosted: Sat Mar 20, 2004 9:52 pm   Post subject: (No subject)

indeed. it is going offtopic. I shall add one piece though: Paint can resive images too, you just have to be sneaky. All you do is change the zoom level and then hit print screen, paste it into a new window, select the part that you want, and save it!

now, back to the topic at hand!! We wait until Bunny has another question Smile
TheZsterBunny




PostPosted: Sat Mar 20, 2004 11:23 pm   Post subject: (No subject)

*sigh* I wish I'd known sooner

I've hand tooled 4 pictures for this project in paint.

Down to the last pixel (pictures are 786x500)

Function works great, but I am having a strange error with my save/load function.


code:

I/O attempted on unopened stream number -10. Open failed with message 'Access (permission) denied'.


Its my computer, I have admin access, I haven't had any errors before.
What the h3ll is happening?

-------Edited-------

Okay, I figured out what was happening. I can't explain it, but I understand what I did wrong. It couldn't open the file, because there was no file to open. But it didn't return file not found error. Hidden files?

-------Unedited-------

SaveLoad:

code:

proc saveload
    put "Please select an option: "
    put "1. Save Game "
    put "2. Load Game "
    put "3. Return "
    put "Choice: " ..
    get input
    if strintok (input) and (strint (input) = 1 or strint (input) = 2) then
        selection := strint (input)
        file := Window.Open ("position:center;center,text:25;50,nobuttonbar,title: Save/Load Game")
        Window.SetActive (file)
        if selection = 1 then
            put "Enter a name for your save file: " ..
            get input : *
            open : dataget, "data/save/" + input + ".rsv", put
            put : dataget, maxplrno
            for i : 0 .. 39
                put : dataget, (pwnzr (i) * 100) + harmy (i)
            end for
            put : dataget, plrno
            put : dataget, turn
            close (dataget)
        elsif selection = 2 then
            dataget := Dir.Open ("data/save/")
            counter := 0
            loop
                strget := Dir.Get (dataget)
                exit when strget = ""
                if index (strget, ".rsv") not= 0 then
                    counter += 1
                    put counter, ". ", strget (1 .. (index (strget, ".rsv") - 1))
                end if
            end loop
            Dir.Close (dataget)
            put ""
            put "Which game number do you wish to load: " ..
            get input : *
            if strintok (input) and strint (input) >= 1 and strint (input) <= counter then
                dataget := Dir.Open ("data/save/")
                selection := strint (input)
                for i : 1 .. selection
                    strget := Dir.Get (dataget)
                end for
                Dir.Close (dataget)
                open : dataget, "data/save/" + strget, get
                get : dataget, maxplrno
                for i : 0 .. 39
                    get : dataget, strget : *
                    pwnzr (i) := strint (strget (1))
                    harmy (i) := strint (strget (2 .. 3))
                end for
                get : dataget, plrno
                get : dataget, turn
                close (dataget)
                updatemap
            end if
        end if
        Window.Close (file)
    end if
end saveload


Oh and finally, Mr.M, here is my function:
p.s. don't mind the nesting

code:

function countryselect : int
    loop
        if Window.GetActive = text and hasch then
            Window.Select (text)
            get input
            if strintok (input) and strint (input) >= 0 and strint (input) <= 39 then
                sel := strint (input)
                Window.Select (text)
                result sel
            end if
        elsif Window.GetActive = map then
            Window.Select (map)
            mousewhere (mx, my, mb)
            if mb not= 0 and mx >= 0 and mx <= maxx and my >= 0 and my <= maxy and whatdotcolor (mx, my) not= whatdotcolor (1, 1) then
                drawfill (mx, my, prettycolor (-1), black)
                for i : 1 .. 46
                    if whatdotcolor (megaplot (i, 1), megaplot (i, 2)) = prettycolor (-1) then
                        drawfill (megaplot (i, 1), megaplot (i, 2), prettycolor (pwnzr (megaplot (i, 0))), black)
                        sel := megaplot (i, 0)
                        result sel
                    end if
                end for
            end if
        end if
    end loop
end countryselect


put "Select a country: " ..
selection := countryselect
if Window.GetActive = map then
    Window.Select (text)
    put selection
end if




*whew*

-bunny

p.s. the_short_1, i've included save and load functions. no coord sending required!
TheZsterBunny




PostPosted: Mon Mar 22, 2004 9:51 pm   Post subject: (No subject)

So i built this project for my screen resolution (1280x1024), keeping in mind that I would have to change it when I got to school (not 1280x1024).

Purposly, i chose not to have any huge pictures.

I arrive at my school computer, and find that my turing file is incorrect because I use a non-default font in the turing window at home.

I spend 20 mins getting everything to align again.

I then find out that my computer at school is messed up, and the resolution i must design it for is (800x600).

I spend 2 hours after school remeasuring and redrawing everything.

(don't have irfan view there)

Today has been a sucky day for turing

-bunny

p.s. if anyone can teach me about Turing and Net module, please do
the_short1




PostPosted: Mon Mar 22, 2004 11:02 pm   Post subject: (No subject)

yea you should know this.... to make a window the size of screen.....

use
View.Set ("graphics:788;540,nobuttonbar")
you cant go 800x600 cuz of title bar adn task bar ETC.....
therfore u should prob not have ur pics exactly 800x600.... u prob know this.,.. but ill state anyways...

at least if u got a cool program like irfanview you can resize to the pixel....


thx for taking my suggestion... also... if you need some net functions... to send co ords.... VOILA! try learning off of this file:
http://www.compsci.ca/v2/download.php?id=1287
its a chat thingy... and if instead of asking the user for 'message' remove and auto make message=new co-ords... hope that helps
TheZsterBunny




PostPosted: Tue Mar 23, 2004 7:47 am   Post subject: (No subject)

Nice file.

However, I'm on a network and it returns my network IP address.
Something no one from the outside can connect to.

Also, Risk can support up to 6 players.

However, this program looks nifty, and i bet it doesn't have the same irritating sounds as MSN Messanger.

Thanks

-bunny
the_short1




PostPosted: Tue Mar 23, 2004 7:54 am   Post subject: (No subject)

yea i got that from my Turing directory under examples.. so its not mine...
cool stuff 6 ppl!!!....can't wait for the next versions


r u going to do an AI?? that mite be tough.... but that would make it the BEST.... and FP Contest worthy....... and if i like it lots... (im a risk fan) ill give ya some bits (notice my large stash) ... but its gota be good.... u already made it look good... now it just needs to play good (over the net/AI/etc)

EDIT: do u got turing at home??...if yes try it there.....

TIP: fun stuff... sneak into a computer lab at lunch... pass around DOOM 2 and have a huge network battle with like TONS of ppl....<<just dont get cought> Wink LaughingLaughingLaughing
TheZsterBunny




PostPosted: Tue Mar 23, 2004 7:56 am   Post subject: (No subject)

So, here is a little breakdown of the game features

3 windows for most of the game. One lists all the countries, owners of the countries, continent, number of armies. (one big list)

beneath that it shows you a list of the players (color, name, whose turn it is, number of countries owned)

to the left of this, we have a nice hand-tooled map with numbers on each of the 40 countries and lines through the ocean to show attackable countries.

beneath this, we have a text window in which most of the input takes place. However, countries can be selected by typing in the corresponding number or clicking the country (thanks to our nifty whatdotcolor function)

Graphics for battles are provided by Advance Wars, sounds from Worms 3D, and battlegrounds from Win XP.

This should be avaliable next week.

-bunny

p.s. does anyone know where I can find animated Advance Wars pictures?
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  [ 15 Posts ]
Jump to:   


Style:  
Search: