Turing Memory program
Author |
Message |
blackviper
|
Posted: Sun Dec 02, 2007 2:27 pm Post subject: Turing Memory program |
|
|
hey this is probably a really easy thing to do but i can seem to get the cards to stay in place when a button is clicked on.....i also want that when one button gets clicked and the other one is clicked and they are the same to cancel out and dissappear.....any help is appreciated.....i have been up for since 10:00 am working on this and its now 2:00 pm......i am very tired, in between ive done other homework but i cant figure this out any help is greatly appreciated
edit** the names for the cards when flipped are just tester names.....dont poke fun at them....lol
heres the code i have
Quote: % define 4 borders of button
setscreen ("graphics")
const xmin := 100
const ymin := 40
const xmax := 200
const ymax := 75
var xloc, yloc, button : int
drawbox (xmin, ymin, xmax, ymax, black)
drawfill (xmin + 1, ymin + 1, darkgray, black)
locatexy (xmin + 5, ymin + 13)
put "card 1" ..
const xmin2 := 300
const ymin2 := 40
const xmax2 := 400
const ymax2 := 75
var xloc2, yloc2 : int
drawbox (xmin2, ymin2, xmax2, ymax2, black)
drawfill (xmin2 + 1, ymin2 + 1, darkgray, black)
locatexy (xmin2 + 30, ymin2 + 13)
put "card 2" ..
const xmin3 := 500
const ymin3 := 40
const xmax3 := 600
const ymax3 := 75
var xloc3, yloc3 : int
drawbox (xmin3, ymin3, xmax3, ymax3, black)
drawfill (xmin3 + 1, ymin3 + 1, darkgray, black)
locatexy (xmin3 + 30, ymin3 + 13)
put "card 3" ..
const xmin4 := 100
const ymin4 := 100
const xmax4 := 200
const ymax4 := 140
var xloc4, yloc4 : int
drawbox (xmin4, ymin4, xmax4, ymax4, black)
drawfill (xmin4 + 1, ymin4 + 1, darkgray, black)
locatexy (xmin4 + 30, ymin4 + 13)
put "card 4" ..
const xmin5 := 300
const ymin5 := 100
const xmax5 := 400
const ymax5 := 140
var xloc5, yloc5 : int
drawbox (xmin5, ymin5, xmax5, ymax5, black)
drawfill (xmin5 + 1, ymin5 + 1, darkgray, black)
locatexy (xmin5 + 30, ymin5 + 13)
put "card 5" ..
const xmin6 := 500
const ymin6 := 100
const xmax6 := 600
const ymax6 := 140
var xloc6, yloc6 : int
drawbox (xmin6, ymin6, xmax6, ymax6, black)
drawfill (xmin6 + 1, ymin6 + 1, darkgray, black)
locatexy (xmin6 + 30, ymin6 + 13)
put "card 6" ..
const xmin7 := 100
const ymin7 := 150
const xmax7 := 200
const ymax7 := 200
var xloc7, yloc7 : int
drawbox (xmin7, ymin7, xmax7, ymax7, black)
drawfill (xmin7 + 1, ymin7 + 1, darkgray, black)
locatexy (xmin7 + 30, ymin7 + 13)
put "card 7" ..
const xmin8 := 300
const ymin8 := 150
const xmax8 := 400
const ymax8 := 200
var xloc8, yloc8 : int
drawbox (xmin8, ymin8, xmax8, ymax8, black)
drawfill (xmin8 + 1, ymin8 + 1, darkgray, black)
locatexy (xmin8 + 30, ymin8 + 13)
put "card 8" ..
const xmin9 := 500
const ymin9 := 150
const xmax9 := 600
const ymax9 := 200
var xloc9, yloc9 : int
drawbox (xmin9, ymin9, xmax9, ymax9, black)
drawfill (xmin9 + 1, ymin9 + 1, darkgray, black)
locatexy (xmin9 + 30, ymin9 + 13)
put "card 9" ..
const xmin10 := 100
const ymin10 := 230
const xmax10 := 200
const ymax10 := 260
var xloc10, yloc10 : int
drawbox (xmin10, ymin10, xmax10, ymax10, black)
drawfill (xmin10 + 1, ymin10 + 1, darkgray, black)
locatexy (xmin10 + 30, ymin10 + 13)
put "card 10" ..
const xmin11 := 300
const ymin11 := 230
const xmax11 := 400
const ymax11 := 260
var xloc11, yloc11 : int
drawbox (xmin11, ymin11, xmax11, ymax11, black)
drawfill (xmin11 + 1, ymin11 + 1, darkgray, black)
locatexy (xmin11 + 30, ymin11 + 13)
put "card 11" ..
const xmin12 := 500
const ymin12 := 230
const xmax12 := 600
const ymax12 := 260
var xloc12, yloc12 : int
drawbox (xmin12, ymin12, xmax12, ymax12, black)
drawfill (xmin12 + 1, ymin12 + 1, darkgray, black)
locatexy (xmin12 + 30, ymin12 + 13)
put "card 12" ..
loop
mousewhere (xloc, yloc, button)
mousewhere (xloc2, yloc2, button)
mousewhere (xloc3, yloc3, button)
mousewhere (xloc4, yloc4, button)
mousewhere (xloc5, yloc5, button)
mousewhere (xloc6, yloc6, button)
mousewhere (xloc7, yloc7, button)
mousewhere (xloc8, yloc8, button)
mousewhere (xloc9, yloc9, button)
mousewhere (xloc10, yloc10, button)
mousewhere (xloc11, yloc11, button)
mousewhere (xloc12, yloc12, button)
if button = 1 and xloc > xmin and xloc < xmax and yloc > ymin and yloc < ymax then
drawbox (xmin, ymin, xmax, ymax, black)
drawfill (xmin + 1, ymin + 1, darkgray, black)
cls
drawbox (xmin, ymin, xmax, ymax, black)
drawfill (xmin + 1, ymin + 1, darkgray, black)
Draw.Text ("Hippo", 120, 50, defFontID, red)
drawbox (xmin2, ymin2, xmax2, ymax2, black)
drawfill (xmin2 + 1, ymin2 + 1, darkgray, black)
Draw.Text ("card 2", 200, 50, defFontID, red)
elsif button = 1 and xloc > xmin2 and xloc < xmax2 and yloc > ymin2 and yloc < ymax2 then
drawbox (xmin, ymin, xmax, ymax, black)
drawfill (xmin + 1, ymin + 1, darkgray, black)
Draw.Text ("Tiger", 100, 30, defFontID, red)
elsif button = 1 and xloc > xmin3 and xloc < xmax3 and yloc > ymin3 and yloc < ymax3 then
drawbox (xmin, ymin, xmax, ymax, black)
drawfill (xmin + 1, ymin + 1, darkgray, black)
Draw.Text ("Duck", 100, 30, defFontID, red)
elsif button = 1 and xloc > xmin4 and xloc < xmax4 and yloc > ymin4 and yloc < ymax4 then
drawbox (xmin, ymin, xmax, ymax, black)
drawfill (xmin + 1, ymin + 1, darkgray, black)
Draw.Text ("Man Bear Pig", 100, 30, defFontID, red)
elsif button = 1 and xloc > xmin4 and xloc < xmax4 and yloc > ymin4 and yloc < ymax4 then
drawbox (xmin, ymin, xmax, ymax, black)
drawfill (xmin + 1, ymin + 1, darkgray, black)
Draw.Text ("Laser Beam Sharks", 100, 30, defFontID, red)
elsif button = 1 and xloc > xmin4 and xloc < xmax4 and yloc > ymin4 and yloc < ymax4 then
drawbox (xmin, ymin, xmax, ymax, black)
drawfill (xmin + 1, ymin + 1, darkgray, black)
Draw.Text ("Duck", 100, 30, defFontID, red)
elsif button = 1 and xloc > xmin5 and xloc < xmax5 and yloc > ymin5 and yloc < ymax5 then
drawbox (xmin, ymin, xmax, ymax, black)
drawfill (xmin + 1, ymin + 1, darkgray, black)
Draw.Text ("Hippopotamus", 100, 30, defFontID, red)
elsif button = 1 and xloc > xmin6 and xloc < xmax6 and yloc > ymin6 and yloc < ymax6 then
drawbox (xmin, ymin, xmax, ymax, black)
drawfill (xmin + 1, ymin + 1, darkgray, black)
Draw.Text ("Tiger", 100, 30, defFontID, red)
elsif button = 1 and xloc > xmin7 and xloc < xmax7 and yloc > ymin7 and yloc < ymax7 then
drawbox (xmin, ymin, xmax, ymax, black)
drawfill (xmin + 1, ymin + 1, darkgray, black)
Draw.Text ("Zebra", 100, 30, defFontID, red)
elsif button = 1 and xloc > xmin8 and xloc < xmax8 and yloc > ymin8 and yloc < ymax8 then
drawbox (xmin, ymin, xmax, ymax, black)
drawfill (xmin + 1, ymin + 1, darkgray, black)
Draw.Text ("Man Bear Pig", 100, 30, defFontID, red)
elsif button = 1 and xloc > xmin9 and xloc < xmax9 and yloc > ymin9 and yloc < ymax9 then
drawbox (xmin, ymin, xmax, ymax, black)
drawfill (xmin + 1, ymin + 1, darkgray, black)
Draw.Text ("Laser Beam Shark", 100, 30, defFontID, red)
elsif button = 1 and xloc > xmin10 and xloc < xmax10 and yloc > ymin10 and yloc < ymax10 then
drawbox (xmin, ymin, xmax, ymax, black)
drawfill (xmin + 1, ymin + 1, darkgray, black)
Draw.Text ("Ruffl", 100, 30, defFontID, red)
elsif button = 1 and xloc > xmin11 and xloc < xmax11 and yloc > ymin11 and yloc < ymax11 then
drawbox (xmin, ymin, xmax, ymax, black)
drawfill (xmin + 1, ymin + 1, darkgray, black)
Draw.Text ("lololo", 100, 30, defFontID, red)
elsif button = 1 and xloc > xmin12 and xloc < xmax12 and yloc > ymin12 and yloc < ymax12 then
drawbox (xmin, ymin, xmax, ymax, black)
drawfill (xmin + 1, ymin + 1, darkgray, black)
Draw.Text ("orange", 100, 30, defFontID, red)
%elsif button = 1 and xloc12 >= xmin12 then
% and xloc12 <= xmax12 and yloc12 >= ymin12
% and yloc12 <= ymax12
end if
end loop
locatexy (xmin2 + 5, ymin2 + 13)
put "Zebra"
locatexy (xmin3 + 5, ymin3 + 13)
put "Tiger"
locatexy (xmin4 + 5, ymin4 + 13)
put "Duck"
locatexy (xmin5 + 5, ymin5 + 13)
put "Man Bear Pig"
locatexy (xmin6 + 5, ymin6 + 13)
put "Laser Beam Sharks"
locatexy (xmin7 + 5, ymin7 + 13)
put "Duck"
locatexy (xmin8 + 5, ymin8 + 13)
put "Hippopotamus"
locatexy (xmin9 + 5, ymin9 + 13)
put "TIGER"
locatexy (xmin10 + 5, ymin10 + 13)
put "Zebra"
locatexy (xmin11 + 5, ymin11 + 13)
put "Man bear Pig"
locatexy (xmin12 + 5, ymin12 + 13)
put "Laser Beam Sharks"
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Ultrahex
|
Posted: Mon Dec 10, 2007 11:05 am Post subject: Re: Turing Memory program |
|
|
Since it appears no-one wants to respond to your post I will.
First of all, it may actually be easier to Use Font.Draw for drawing the names on top of cards (instead of using Locate) so you can properly center the name. (which will help you fix your movement problem due to using locate.)
Also when you do mousewhere ... you only need one, mousewhere gets the current location of the mouse at that point in time... You do not need a set for each check.
Basically you need a boolean for each card changing it if they do click two of the same, and only draw the cards that are shown.
Also additional tips: (There is Tutorials for most of these, if not all. Also check Turing Documentation)
make a type/structure for a card which could include such information as is it currently shown, what is hidden.
Show the card name when you click on top of the card.
Use an array to store all your cards, and then make a procedure to draw all your cards.
If you need anymore help reply in this post. |
|
|
|
|
|
|
|