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

Username:   Password: 
 RegisterRegister   
 Whatdotcolor
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Tuxedo




PostPosted: Tue Jan 04, 2005 9:47 pm   Post subject: Whatdotcolor

Why do I get an error? What parameters am I missing?


[\code] procedure hit (x1, y1:int)
var change:=0
if whatdotcolor (x1, y1)= 3 then
put "HITTTTTY"
delay (1000)

end if
end hit [code\]


ps...how do you do the code label?



I know you probably think I am a lamer but can you help and I plan to stay and contribute to the forums after I develop some skill... Very Happy
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Tue Jan 04, 2005 9:53 pm   Post subject: (No subject)

Error? There's no error. Maybe you're calling it wrong.
as for code tags:
code:

This is code, because I put a [code] in front of it and ended it with a [/code]


EDIT: no, you're not a lamer for asking questions. We all did at some point. And we all will continue to ask questions for the rest of our lives.
Tuxedo




PostPosted: Tue Jan 04, 2005 9:55 pm   Post subject: (No subject)

O thanks I see the code] things now!


This is the full thing but I don't see what is wrong and have tried to compare to different programs but am stumped...It is probably really obvious but I am just starting....

code:
setscreen ("graphics:v16,nocursor,noecho")
var reply : string (1)
var direction : string
var x1 : int := 0
var y1 : int := 0
var moves : int := 200
var ammo : int := 50
var change : int:= 0
%%%%%%%%%%%%*****************************************************************************
%<<HUNTER>>%*****************************************************************************
%%%%%%%%%%%%*****************************************************************************
procedure hunter
    var x, y, x1, y1 : int
    x := 20
    y := 20
    x1 := 20
    y1 := 20
    var change : int := 5
    drawfilloval (x, y, 10, 10, 1)

    var reply : string (1)
    var direction : string

    %%%%%%%%%%%%%%%%%%%%
    %CHARACTER MOVEMENT%
    %%%%%%%%%%%%%%%%%%%%
    loop
        getch (reply)
        if reply = chr (200) then %up arrow
            y := y + 10
            y1 := y1 + 10
            moves := moves - 1
            delay (5)
            cls
            drawfilloval (x, y, 10, 10, 1)
            exit when moves = 0
            color (4)
            put "MOVES REMAINING :", moves
            put " AMMO :", ammo
        elsif reply = chr (208) then %down arrow
            y := y - 10
            y1 := y1 - 10
            moves := moves - 1
            delay (5)
            cls
            drawfilloval (x, y, 10, 10, 1)
            drawfilloval (200,300,6,6,14)
            exit when moves = 0
            put "MOVES REMAINING :", moves
            put " AMMO :", ammo
        elsif reply = chr (203) then %left arrow
            x := x - 10
            x1 := x - 10
            moves := moves - 1
            delay (5)
            cls
            drawfilloval (x, y, 10, 10, 1) %right arrow
            exit when moves = 0
            put "MOVES REMAINING :", moves
            put " AMMO :", ammo
        elsif reply = chr (205) then
            x := x + 10
            x1 := x1 + 10
            moves := moves - 1
            delay (5)
            cls
            drawfilloval (x, y, 10, 10, 1)
            exit when moves = 0
            put "MOVES REMAINING :", moves
            drawfilloval (300, 200, 7, 7, 14)
            put " AMMO :", ammo
            %%%%%%%%%%
            %SHOOTING%
            %%%%%%%%%%

        elsif reply = chr (117) then %SHOOTING UP   (u)
            for count : 1 .. 30
                drawfilloval (x1, y1 + change, 2, 2, 12)
                change := change + 5
            end for
            ammo := ammo - 1
            delay (100)
            change := 0
            exit when ammo = 0
            put " AMMO :", ammo

        elsif reply = chr (106) then %SHOOTING DOWN (j)
            for count : 1 .. 30
                drawfilloval (x1, y1 + change, 2, 2, 12)
                change := change - 5
            end for
            ammo := ammo - 1
            delay (100)
            change := 0
            exit when ammo = 0
            put " AMMO :", ammo

        elsif reply = chr (107) then %SHOOTING RIGHT (k)
            for count : 1 .. 30
                drawfilloval (x1 + change, y1, 2, 2, 12)
                change := change + 5
            end for
            ammo := ammo - 1
            delay (100)
           
            change := 0
            exit when ammo = 0
            put " AMMO :", ammo

        elsif reply = chr (104) then %SHOOTING LEFT (h)
            for count : 1 .. 30
                drawfilloval (x1 + change, y1, 2, 2, 12)
                change := change - 5
            end for
            ammo := ammo - 1
            delay (100)
            change := 0
            delay (100)
            change := 0
            exit when ammo = 0
            put " AMMO :", ammo
        end if
    end loop
end hunter
%%%%%%%%%%%%%%%%%%%%
procedure hit (x1, y1 : int)

    if whatdotcolor (x1+5, y1 ) = 14 then
        locate (20, 25)
        put "HIT"

    end if
end hit

%%%%%%%%%%%%%%%%%%%%*****************************************************************
%<<OPENING SCREEN>>%*****************************************************************                                                                                         *
%%%%%%%%%%%%%%%%%%%%*****************************************************************
var openingChange : int := 0
procedure openingScreen

    color (4)
    loop
        put "" %program comments
        put "Version 1.0"
        put "December 7, 2004"
        put "Zack Melnyk"
        locate (28, 25)
        put "Hit any key to continue"

        drawfillbox (380, 210, 410, 180, 6) %HOBO HEAD
        drawline (380, 210, 378, 219, 8) %HOBO HAIR   LEFT
        drawline (381, 210, 380, 223, 8)
        drawline (382, 210, 382, 225, 8)
        drawline (384, 210, 383, 225, 8)
        drawline (385, 210, 385, 223, 8)
        drawline (386, 210, 387, 219, 8)
        drawline (410, 210, 412, 219, 8) %HOBO HAIR  RIGHT
        drawline (409, 210, 410, 223, 8)
        drawline (408, 210, 408, 225, 8)
        drawline (406, 210, 407, 223, 8)
        drawline (405, 210, 405, 219, 8)
        drawline (404, 210, 403, 219, 8)
        drawfilloval (385, 200, 2, 2, 9) %HOBO EYE LEFT
        drawfilloval (405, 200, 2, 2, 9) %HOBO EYE RIGHT
        drawfillbox (375, 180, 415, 125, 5) %HOBO TORSO
        drawline (382, 170, 382, 125, 13) %HOBO ARMS
        drawline (409, 170, 409, 125, 13)
        drawfillbox (375, 125, 415, 140, 7) %HOBOLEGS
        drawbox (375, 125, 415, 140, 15)

        drawoval (0 + openingChange, 200, 60, 60, 4) %CROSS HAIRS
        drawline (0 + openingChange, 140, 0 + openingChange, 260, 4)
        drawline (60 + openingChange, 200, - 60 + openingChange, 200, 4)
        drawoval (0 + openingChange, 200, 20, 20, 4)
        drawoval (0 + openingChange, 200, 62, 62, 4)

        delay (55)
        cls
        openingChange := openingChange + 3
        exit when openingChange >= 400

    end loop
    put ""
    put "Version 1.0" %program comments
    put "December 7, 2004"
    put "Zack Melnyk"
    locate (30, 25)
    put "Hit any key to continue"

    %%%%%%%%%%%
    %DEAD HOBO%
    %%%%%%%%%%%
    drawfillbox (380, 210, 410, 180, 6) %HOBO HEAD
    drawline (380, 210, 378, 219, 8) %HOBO HAIR   LEFT
    drawline (381, 210, 380, 223, 8)
    drawline (382, 210, 382, 225, 8)
    drawline (384, 210, 383, 225, 8)
    drawline (385, 210, 385, 223, 8)
    drawline (386, 210, 387, 219, 8)
    drawline (410, 210, 412, 219, 8) %HOBO HAIR  RIGHT
    drawline (409, 210, 410, 223, 8)
    drawline (408, 210, 408, 225, 8)
    drawline (406, 210, 407, 223, 8)
    drawline (405, 210, 405, 219, 8)
    drawline (404, 210, 403, 219, 8)
    drawfilloval (385, 200, 2, 2, 9) %HOBO EYE LEFT
    drawfilloval (405, 200, 2, 2, 9) %HOBO EYE RIGHT
    drawfillbox (375, 180, 415, 125, 5) %HOBO TORSO
    drawline (382, 170, 382, 125, 13) %HOBO ARMS
    drawline (409, 170, 409, 125, 13)
    drawfillbox (375, 125, 415, 140, 7) %HOBOLEGS
    drawbox (375, 125, 415, 140, 15)

    drawoval (400, 200, 60, 60, 4) %cross hairs
    drawline (400, 140, 400, 260, 4)
    drawline (460, 200, 340, 200, 4)
    drawoval (400, 200, 20, 20, 4)
    drawoval (400, 200, 62, 62, 4)
    delay (3000)
end openingScreen

%%%%%%%%%%%%%%%%%%***************************************************************************
%<<INSTRUCTIONS>>%***************************************************************************
%%%%%%%%%%%%%%%%%%***************************************************************************

procedure instructions
    color (4)
    locate (1, maxcol div 2 - 8)
    put "*****MISSION BRIEFING*****"
    put " "
    put "The Hobos are taking over the town and we need you deal with them"
    put "I expect that you will be able to strike them down on sight"
    put "you have been armed with an T12 Tranquilizing dart gun. We"
    put "have not got much time so get out there and stop them before"
    put "It is to late!"
    put " "
    put " "
    put "Shoot hobos to earn points. Each Hobo will earn you 10"
    put "Move the Hunter around by pressing the arrow keys in"
    put "direction you wish to move."
    put "To shoot your tranquilizer you must press the corresponding button:"
    put "To shoot UP press 'u'"
    put "To shoot DOWN press 'j'"
    put "to shoot LEFT press 'h'"
    put "to shoot RIGHT press 'k'"
end instructions
%%%%%%%%%%%%%
%LOSE SCREEN%
%%%%%%%%%%%%%
procedure lose
    cls
    color (4)
    put "YOU LOSE!!!"
end lose
%%%%%%%%%%%%%%%%%%******************************************************************************
%<<MAIN PROGRAM>>%******************************************************************************
%%%%%%%%%%%%%%%%%%******************************************************************************
%openingScreen

%getch (reply)
%cls
%instructions
hit (x1+change, y1)
hunter
lose




apparently not....
Neo




PostPosted: Tue Jan 04, 2005 10:13 pm   Post subject: (No subject)

Because you have [code],[code],[/code].
Cervantes




PostPosted: Tue Jan 04, 2005 10:18 pm   Post subject: (No subject)

Yep, as I suspected. See, when you wrote your procedure, you gave it two parameters. You called those parameters x1 and y1, and they were both integers. Now, when you call the procedure, you aren't passing any parameters to it. You need to do something like this:
code:

hit(variable1_to_be_passed_into_the_procedure_as_x1, variable2_to_be_passed_into_the_procedure_as_y1)

Which variable you use is up to you.
I feel like I've said this before... Thinking
Tuxedo




PostPosted: Tue Jan 04, 2005 10:26 pm   Post subject: (No subject)

AHHHH!!!...I would give up all 17 of my bits to figure this out!!!! Twisted Evil Laughing


Can you please put this in the code where I would need it and I will try to be the best noob to ever cross compsci in the history of compsci!

I just can't understand where it goes and what to put... Crying or Very sad
Cervantes




PostPosted: Tue Jan 04, 2005 10:33 pm   Post subject: (No subject)

Here's the chunk of code that you're going to modify:
code:

getch (reply)
cls
instructions
hit
hunter

change it to this:
code:

getch (reply)
cls
instructions
hit(variable1_to_be_passed_into_the_procedure_as_x1, variable2_to_be_passed_into_the_procedure_as_y1)
hunter

and, obviously, fix the variables that you pass to the hit procedure.
Tuxedo




PostPosted: Tue Jan 04, 2005 10:49 pm   Post subject: (No subject)

I am probably really stupid or OOT 3.1.1 don't do what you saying to do...however I still am unable get it to work. Embarassed I am probably really peeing you of but please be patient with a noob because I am trying really....hard! Sad


***wait I think it works!!!! false alarm... var has no value?
Sponsor
Sponsor
Sponsor
sponsor
Neo




PostPosted: Wed Jan 05, 2005 9:20 am   Post subject: (No subject)

Tuxedo wrote:

***wait I think it works!!!! false alarm... var has no value?


You have to initialize variables before you can use them.
So if you set up a variable:
var x:int
then u must do
x=20
or something similar
Tuxedo




PostPosted: Sat Jan 08, 2005 4:20 pm   Post subject: (No subject)

I have probably spent more than 4 hours trying to gte this whatdotcolor to work can anybody please just show me how to put it in my code? can you make it hit a yellow dot on the screen that is all I want and am starting to become really frustrated! I am sure it is really easy once I figure it out but as of now am stumped as to why it will not detect... Crying or Very sad


The updated code is above ^^^^^
Tuxedo




PostPosted: Sun Jan 09, 2005 7:00 pm   Post subject: (No subject)

Nobody....I am in dire need please help Crying or Very sad


I do not mean to be a nuisance but have tried all you have said? It will go into the program but not detect? Am I drwing in the wrong place?
Cervantes




PostPosted: Sun Jan 09, 2005 7:27 pm   Post subject: (No subject)

I don't really know what you are asking for, so I wrote this. Hopefully it will answer your question.
code:

setscreen ("offscreenonly")
var player :
    record
        x, y, radius : int
    end record

player.x := 0
player.y := 0
player.radius := 10

const gun_range := 50

var hit := false
var keys : array char of boolean

loop

    Input.KeyDown (keys)
    if keys (KEY_UP_ARROW) then
        player.y += 1
    end if
    if keys (KEY_DOWN_ARROW) then
        player.y -= 1
    end if
    if keys (KEY_RIGHT_ARROW) then
        player.x += 1
    end if
    if keys (KEY_LEFT_ARROW) then
        player.x -= 1
    end if

    for c : player.radius .. player.radius + gun_range
        if whatdotcolour (player.x + c, player.y) = yellow then
            hit := true
        end if
    end for
    cls
    drawline (player.x + player.radius, player.y, player.x + player.radius + gun_range, player.y, brightred)
    drawfilloval (player.x, player.y, player.radius, player.radius, blue)
    drawfilloval (100, 100, 10, 10, yellow)
    View.Update
    delay (10)

    exit when hit
end loop
Tuxedo




PostPosted: Sun Jan 09, 2005 7:41 pm   Post subject: (No subject)

I really appreciate your help but I am unable to use that type of code. I will just have to leave out whatdotcolor and take a bad mark and try to figure this thing out when I am under no pressure and at my leisure. Thankyou Cervantes and Neo Wink



Neo you can have +4 bits all I have... Smile


unless you can change that code to using crappy old turing...the one with the blck screen like DOS. No update or (key.up)...etc. Would help me alot Confused
Tuxedo




PostPosted: Sun Jan 09, 2005 8:20 pm   Post subject: (No subject)

I have managed to gte whatdotcolro to work!!! However when I do it one time it....scratch that!!!


edit:
I now have it working as whatdotcolor I have fixed the problem through changing something else when you fire twice without shooting in a different direction your gun overheats...I may change that to move in a different direction. W/e... I am stumped on where to put the object in the code that I will hit? Do I need to put them in before the cls and after the cls in the moves? Or am I thinking the wrong way?
Cervantes




PostPosted: Sun Jan 09, 2005 10:00 pm   Post subject: (No subject)

Oww, that's a lot of code. You got the wrong slash in the [/code] Wink Please, when you're posting that much code, do it as an attachment. It saves bandwidth for Dan and saves all of our scroll bars.

I'm still not really grasping the idea of your program. I'm kind of confused as to why the yellow circle disappears and reappears based on when you move.
Also, I would highly recommend using Input.KeyDown instead of getch. There's a tutorial here if you want it.
Anyways, I'm not getting this error. Neither am I seeing "HIT!" anywhere, even when I think I've hit the yellow circle.
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 2  [ 17 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: