
-----------------------------------
lzbravo
Fri Jun 10, 2005 6:56 pm

BLOCK DuDE HElp
-----------------------------------
i created a program called block dude just like the one on the Ti graphing calculator, i am able to move around but i am having problems with setting boundaries, picking up and moving blocks, and also freeing pictures. how would i make it so i cna pic up bloacks and move them around the level and drop them in certain palces,  also i would like to know how toset boundaries so my charachter can't move outside of the screen. here is my code so if you could help em with these small problems or give me suggestions on how to fix it it would be a huge help, thanks in advance



%Stefano Beninati
%Mr Paterson
%05/06/05
%block dude
%summative program



%  variables


var x, y, x1, y1, x2, y2, x3, y3 : int
var pic, pic1, newPic, width, height, picID : int
var move, answer : string (1)
x := 520
y := 122

procedure maze
    loop
        %Get the original picture
        pic := Pic.FileNew ("mario4.bmp")
        % draws boarder

        drawfillbox (0, 0, 640, 480, black) %draws black boarder
        drawfillbox (20, 20, 620, 380, 104) %draws white background
        % draws blocks

        drawfillbox (420, 20, 440, 40, 45)
        drawfillbox (140, 20, 160, 40, 45)
        drawfillbox (140, 40, 160, 60, 45)
        drawfillbox (160, 20, 180, 40, 45)
        drawfillbox (20, 80, 40, 100, 45)
        drawfillbox (40, 80, 60, 100, 45)
        drawfillbox (20, 100, 40, 120, 45)
        drawfillbox (180, 140, 200, 160, 45)
        drawfillbox (200, 140, 220, 160, 45)
        drawfillbox (220, 140, 240, 160, 45)
        drawfillbox (200, 160, 220, 180, 45)
        drawfillbox (600, 120, 620, 140, 45)
        drawfillbox (580, 120, 600, 140, 45)
        drawfillbox (600, 140, 620, 160, 45)
        drawfillbox (600, 140, 620, 160, 45)
        drawfillbox (460, 260, 480, 280, 45)

        %level layout
        drawfillbox (20, 61, 140, 80, white)
        drawfillbox (500, 100, 620, 120, white)
        drawfillbox (480, 20, 500, 100, white)
        drawfillbox (440, 20, 460, 100, white)
        drawfillbox (360, 20, 380, 60, white)
        drawfillbox (240, 20, 300, 40, white)
        drawfillbox (260, 20, 280, 60, white)
        drawfillbox (140, 120, 280, 140, white)
        drawfillbox (60, 160, 120, 180, white)
        drawfillbox (280, 120, 300, 200, white)
        drawfillbox (300, 140, 360, 160, white)
        drawfillbox (340, 140, 360, 200, white)
        drawfillbox (360, 180, 400, 200, white)
        drawfillbox (360, 180, 380, 220, white)
        drawfillbox (400, 200, 420, 220, white)
        drawfillbox (420, 220, 440, 240, white)
        drawfillbox (440, 240, 460, 260, white)
        drawfillbox (460, 240, 500, 260, white)
        drawfillbox (480, 200, 500, 260, white)
        drawfillbox (40, 240, 240, 260, white)
        drawfillbox (40, 320, 240, 340, white)
        drawfillbox (20, 240, 40, 340, white)
        drawfillbox (240, 240, 260, 340, white)
        drawfillbox (500, 200, 560, 220, white)
        drawfillbox (560, 240, 620, 260, white)
        drawfillbox (560, 200, 580, 260, white)
        drawfillbox (580, 260, 620, 320, yellow) %Exit

        % Traps

        drawfillbox (80, 180, 100, 220, 54) %takes user to top of level
        drawfillbox (80, 260, 100, 300, 42) %skill testing question
        drawfillbox (140, 260, 160, 300, 13) %restart the program
        drawfillbox (200, 260, 220, 300, 11) %takes user to prison
        drawfillbox (520, 40, 560, 80, 40) %exit


        %  GRID
        %lines going left to the right
        x2 := 0
        y2 := 0
        x3 := 0
        y3 := 400
        loop
            drawline (x2, y2, x3, y3, 43)
            x2 := x2 + 20
            x3 := x3 + 20
            exit when x2 > 640
        end loop

        %lines going bottom too the top
        x2 := 0
        y2 := 0
        x3 := 640
        y3 := 0
        loop
            drawline (x2, y2, x3, y3, 43)
            y2 := y2 + 20
            y3 := y3 + 20

            exit when y2 > 400
        end loop

        % Exits and traps %

        Pic.Draw (pic, x, y, picCopy) %draws the object

        %%%%%%%%%%%%%%%%%%% Exit fromt the program when user reaches end of maze
        if x > 560 and y > 260 and x < 640 and y < 300 then % End of maze
            cls
            put " Congratulations you have reached the end of the maze"
            exit
        end if

        %%%%%%%%%  Exit when the user goes to jail and moves into thered area
        if x > 500 and y > 40 and x < 560 and y < 60 then %End of programfrom inside of maze
            cls
            put " Sadly you have died in prison " %message
            exit
        end if

        %%%%%%%%% Takes the user to the trap area %%%%%%%%%%%%
        if x > 60 and y > 180 and x < 100 and y < 220 then %takes user to the trap area
            put " you will now have to choose 1 out of the 3 boxes, be carefull ! "


            %%%%%%%%%%%%%%%%%%% Exit fromt the program when user reaches end of maze          %%%%%%%%%%%%%%%%%
            if x > 560 and y > 260 and x < 640 and y < 300 then % End of maze
                cls
                put " Congratulations you have reached the end of the maze"
                cls
            end if

            %%%%%%%%%  Exit when the user goes to jail and moves into the red area       %%%%%%%%%%%%%%%%%
            if x > 500 and y > 40 and x < 560 and y < 60 then %End of
                cls
                put " Sadly you have died in prison " %message
                cls
            end if

            %hen user answer 1 correct, fix lcation

            %%%%%%%%% Takes the user to the trap area %%%%%%%%%%%%
            if x > 60 and y > 180 and x < 100 and y < 220 then %takes user to thetrap area
                put " you will now have to choose 1 out of the 3 doors, be carefull ! "
                delay (2000)
                cls
                put "Which door would you like to enter? (1,2,3)"
                get answer
                if answer = "1" then
                    put " If systems A and B are in thermodynamic equilibrium, and systems B and C are in thermodynamic equilibrium,then systems A and C are also in thermodynamic equilibrium."
                    put "The above statement is:"
                    put " a)Definetly true"
                    put " b)Impossible to predict"
                    put " c)Not true"
                    put " d) 42"
                    get answer
                    if answer = "a" then
                        cls
                    end if
                    if answer = "b" or answer = "c" or answer = "d" then
                        put " sorry you guessed the wrong answer, unfortunatly you lost "
                    end if

                    for i : 1 .. 50
                        x := Rand.Int (42, 62)    % Random x
                        y := Rand.Int (246, 265)    % Random y
                        Pic.Free (pic)
                        cls
                        maze
                        Pic.Draw (pic, 40, 260, picCopy)
                        cls
                    end for
                end if
            end if
        end if

        %%%%%%%%%%%%%%%%%%   moves character   %%%%%%%%%%%%%%
        getch (move)
        if move = chr (200) then
            y := y + 20
        elsif move = chr (203) then
            x := x - 20
        elsif move = chr (205) then
            x := x + 20
        elsif move = chr (208) then
            y := y - 20
        end if


    end loop
end maze
maze[img][/img]

-----------------------------------
Naveg
Fri Jun 10, 2005 7:20 pm


-----------------------------------
1. you have to give us all pictures used with it
2. F2
3. [code]
