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

Username:   Password: 
 RegisterRegister   
 Concentration Game help.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
noname96




PostPosted: Fri Jan 25, 2013 1:38 pm   Post subject: Concentration Game help.

I've completed most of my concentration game, in which you must click on two cards, and if they match they either stay flipped up or disappear, otherwise they return to their face down position. I have NO IDEA how to make this happen. So far on my code, it allows you to click on two cards, and regardless if they match or not, they become face down again after a delay of 1 second.This is due on Monday so i'm fairly desperate. Any help and code would be GREATLY appreciated. thanks:)



Turing:




setscreen ("graphics:1201;601;cursor;nobuttonbar")
View.Set ("offscreenonly")
%%%%%%%%%%%%%%%%%main menu%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure main

    var x : int
    var y : int
    var button : int

    var font1 : int
    font1 := Font.New ("arial:30")

    Draw.FillBox (maxx, maxy, 0, 0, black)
    Font.Draw ("Welcome to Concentration", 300, 474, font1, 2)


    Draw.Box (500, 300, 750, 325, black)

    Font.Draw ("Click to Play!", 500, 300, font1, red)


    loop

        Mouse.Where (x, y, button)
        Text.Locate (1, 1)
        if button = 0 then
            put x : 4, "  ", y : 4, "  button up"
        else
            put x : 4, "  ", y : 4, "  button down"
        end if

        exit when x > 500 and x < 750 and y > 300 and y < 325 and button not= 0

    end loop
    cls
end main




main



Draw.FillBox (0, 1, 1203, 600, 7) %%%%background%%%%%



var font1 : int
font1 := Font.New ("serif:16")
assert font1 > 0
Font.Draw ("Match the Cards!", 737, 318, font1, white)




var stream : int
var word : string
var board : array 1 .. 4, 1 .. 4 of string
var select, match : array 1 .. 4, 1 .. 4 of boolean
var pic : array 1 .. 16 of int
var X : int
var Y : int
var X2 : int
var Y2 : int
var random : array 1 .. 16 of int
var hold : int
var hold2 : int


for r : 1 .. 4
    for c : 1 .. 4

        select (r, c) := true
        match (r, c) := true
    end for
end for



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%assigning each floor of the array a picture%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

pic (1) := Pic.FileNew ("ORANGE.jpg")
pic (2) := Pic.FileNew ("WATERMELON.jpg")
pic (3) := Pic.FileNew ("STRAWBERRIES.jpg")
pic (4) := Pic.FileNew ("PUMPKIN.jpg")
pic (5) := Pic.FileNew ("BANANA.jpg")
pic (6) := Pic.FileNew ("APPLE.jpg")
pic (7) := Pic.FileNew ("GRAPES.jpg")
pic (8) := Pic.FileNew ("MANGO.jpg")
pic (9) := Pic.FileNew ("ORANGE.jpg")
pic (10) := Pic.FileNew ("WATERMELON.jpg")
pic (11) := Pic.FileNew ("STRAWBERRIES.jpg")
pic (12) := Pic.FileNew ("PUMPKIN.jpg")
pic (13) := Pic.FileNew ("BANANA.jpg")
pic (14) := Pic.FileNew ("APPLE.jpg")
pic (15) := Pic.FileNew ("GRAPES.jpg")
pic (16) := Pic.FileNew ("MANGO.jpg")


%%%%%%%%%%%%%%%%%%%%initializes array%%%%%%%%%%%%%%%%%%

for i : 1 .. 16
    random (i) := i
end for


%%%%%%%%%%%%%%%%%%%%%%randomizing array%%%%%%%%%%%%%%%%%%%%%
procedure shuffle
    var Temp, R : int
    for e : 1 .. 3
        for i : 1 .. 16
            R := Rand.Int (1, 16)
            Temp := random (R)
            random (R) := random (i)
            random (i) := Temp
        end for
    end for
end shuffle


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%FACE DOWN CARD%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

var x, y, button : int
var click : boolean := true
procedure fill
    var counter : int := 0
    var x2, x3, y2, y3 : int
    y2 := 543
    y3 := 420
    for i : 1 .. 4
        x2 := 30
        x3 := 150
        for j : 1 .. 4
            counter += 1
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%determining if card should be face up or face down%%%%%%%%%%%%%%%%%%%
            if select (i, j) = true then
                Draw.FillBox (x2, y2, x3, y3, red)
            end if
            if select (i, j) = false then
                Draw.FillBox (x2, y2, x3, y3, white)
                Pic.Draw (pic (random (counter)), x2, y3, picCopy)

                Draw.Box (x2, y2, x3, y3, 3)
            end if



            x2 += 130
            x3 += 130
        end for
        y2 -= 130
        y3 -= 130
    end for
end fill

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%finds the  card you click, and assigns it a true or false value%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure find
    var x2, y2 : int := 0
    Mouse.Where (x, y, button)
    for r : 1 .. 4
        x2 := 0
        for c : 1 .. 4
            if x > 30 + x2 and x < 150 + x2 and y < 542 + y2 and y > 420 + y2 and button not= 0 then
                select (r, c) := false
            end if
            if pic (1) = pic (9) and button not= 0 then
                match (r, c) := false
            end if
            x2 += 130
        end for
        y2 -= 130
    end for
end find



shuffle
loop
    Mouse.Where (x, y, button)
    Text.Locate (1, 1)
    if button = 0 then
        put x : 4, "  ", y : 4, "  button up"
    else
        put x : 4, "  ", y : 4, "  button down"
    end if
    for i : 1 .. 2
        loop
            Mouse.Where (x, y, button)
            exit when button not= 0
        end loop
        find
        fill
        View.Update
        loop
            Mouse.Where (x, y, button)
            exit when button = 0
        end loop
    end for

    delay (1000)

    for i : 1 .. 4
        for j : 1 .. 4
        if match(i,j) = true then
            select (i, j) := true
        end if
        end for
    end for
    fill
    View.Update

end loop




this was my attempt at it, but obviously it doesn't work. (doesn't do anything for that matter) :

Turing:


 if pic (1) = pic (9) and button not= 0 then
                match (r, c) := false


...

Turing:

 for i : 1 .. 4
        for j : 1 .. 4
        if match(i,j) = true then
            select (i, j) := true
        end if
        end for
    end for
    fill
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  [ 1 Posts ]
Jump to:   


Style:  
Search: