Computer Science Canada Selecting dice procedure help |
Author: | LEEEEROYJENKINS [ Tue Dec 13, 2011 9:50 am ] |
Post subject: | Selecting dice procedure help |
Hi, I am new to this site and I have a question about a dice game I am making in class. I have layed out my text (some of it still isn't aligned but I will fix it later ) my big problem is that I need to select a dice and keep it's value, I have drawn the box but I do not know how to get it to move around and to select the value of the dice. Thanks! My code so far : P.S. the procedure "Keep" is the one I need help with var dicey : int var arrow : string (1) var winMain : int := Window.Open ("graphics : 781 ; 541") var font : int := Font.New ("serif:10") var num : int var key : string (1) var die : array 1 .. 3 of int var dicekeep, dicex : array 1 .. 3 of int var X, Y : int := 80 dicex (1) := 100 dicex (2) := 300 dicex (3) := 500 dicey := 100 procedure one (X, Y : int) drawfilloval (X + 70, Y + 70, 5, 5, black) end one procedure two (X, Y : int) drawfilloval (X + 20, Y + 20, 5, 5, black) drawfilloval (X + 120, Y + 120, 5, 5, black) end two procedure three (X, Y : int) one (X, Y) two (X, Y) end three procedure four (X, Y : int) two (X, Y) drawfilloval (X + 20, Y + 120, 5, 5, black) drawfilloval (X + 120, Y + 20, 5, 5, black) end four procedure five (X, Y : int) one (X, Y) four (X, Y) end five procedure six (X, Y : int) four (X, Y) drawfilloval (X + 20, Y + 65, 5, 5, black) drawfilloval (X + 120, Y + 65, 5, 5, black) end six procedure keep (X,Y: int) loop getch (arrow) colorback (7) color (0) Font.Draw (" Welcome to The Dice Game! Intializing... ", 250, 270, font, 1) % adds effect of loading game delay (1000) cls put " The rules are simple, 3 dice, 10 rolls , gather points as you go. Simple. " delay (700) cls put " Here's how you get points.." put " Roll Call " : 20, " Points " : 20 .. %left side of menu put " " : 20 put " " put " Three of a kind " : 20 put " Oddball " : 20 put " Evenball " : 20 put " Straight " : 20 put " pair " : 20 %right side of menu put "" : 20, " 30 " put "" : 20, " 100 " put "" : 20, " 50 " put "" : 20, " 50 " put "" : 20, " 80 " delay (2000) cls put " Use the arrow keys to select a dice press space to keep the selected die's score " %three dice loop drawfillbox (dicex (1), 100, dicex (1) + 140, dicey + 140, red) drawfillbox (dicex (2), 100, dicex (2) + 140, dicey + 140, red) drawfillbox (dicex (3), 100, dicex (3) + 140, dicey + 140, red) for i : 1 .. 3 randint (die (i), 1, 6) if die (i) = 1 then one (dicex (i), dicey) elsif die (i) = 2 then two (dicex (i), dicey) elsif die (i) = 3 then three (dicex (i), dicey) elsif die (i) = 4 then four (dicex (i), dicey) elsif die (i) = 5 then five (dicex (i), dicey) elsif die (i) = 6 then six (dicex (i), dicey) end if end for delay (150) end loop |
Author: | Dreadnought [ Tue Dec 13, 2011 1:48 pm ] |
Post subject: | Re: Selecting dice procedure help |
I'm not sure I understand what your problem is. Is all your code posted? (your keep procedure isn't complete) But to try to answer your question. I think you want some sort of graphic that moves to indicate which die is selected (moving using arrow keys), and you want to keep the value of the selected die in memory if the user presses space. You'll need a variable to keep track of which die is selected, so that you can draw the graphic in the right place. When the user presses space, just copy the value of the die at that moment to another variable. Again, please be more specific in your question (ideally use the form that is given when you create a topic). Especially tell us what you've tried. (none of your code shows that you have tried to do what you're asking about) To make your code look nice when you post, check out http://compsci.ca/v3/viewtopic.php?t=16370 |
Author: | LEEEEROYJENKINS [ Wed Dec 14, 2011 10:05 am ] |
Post subject: | Re: Selecting dice procedure help |
I'm sorry I am new to the forum, I posted another thread with more clarification on what my problem is. I i posted my code right, and included that my procedure was unfinished. Thanks. |