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

Username:   Password: 
 RegisterRegister   
 Need help with first game
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Vertico




PostPosted: Fri Apr 08, 2005 12:59 pm   Post subject: Need help with first game

problem : i want 2 know how i score. i want a point when the wepon (green oval) hits the white oval at the top of the screen. iv tryed and have failed.

i know alot of u can find other problems with my game, like places it could be shortened or were i completly screwed up. but i would like 2 figure out how i code it so i can have score keeping.

plz help me out


code:
colourback (black)
colour (black)
cls

setscreen ("graphics : 600 ; 300")

var Ax, Ay, Astep, radius, Vx, Vy, By, score : int
var key, wep : string (1)
key := ""
wep := ""
radius := 5
Vx := 5
Vy := 5
By := Vy
Ax := 5
Ay := 388
Astep := 5
score := 0

%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%Moster
%%%%%%%%%%%%%%%%%%%%%%%%%%

loop
  color(yellow)
locate(5,30)
put "Score : " , score
color(black)

  %%%Vertico%%%
    drawfilloval (Vx, Vy, radius, radius, blue)
    %%%Moster%%%
    drawfilloval (Ax, Ay, radius+10, radius+10, white)
    delay (10)
    %%%Vertico%%%
    drawfilloval (Vx, Vy, radius, radius, black)
    %%%Moster%%%
    drawfilloval (Ax, Ay, radius+10, radius+10, black)

    %%%Aliens movment.  back and foreth at the top of screen
    Ax := Ax + Astep
    if Ax > 630 - radius then
        Astep := -Astep
    elsif Ax <= 2 then
        Astep := 2
    end if

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%%%%%%%%%%%%%%%%%%Vertico%%%%%%%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%Moving the character
    if hasch then
        getch (key)
        if key = "a" or key = "A" then
            Vx := Vx - 10
        elsif key = "d" or key = "D" then
            Vx := Vx + 10
        elsif key = "w" or key = "W" then
            Vy := Vy + 10
        elsif key = "s" or key = "S" then
            Vy := Vy - 10
        %%%if z or Z is pushed the wepon is activated. by := Vy makes the wepon apear above the
        %%%character. So werever the character is. the wepon will show up there.
            elsif key = "z" or key = "Z" then
  By := Vy
   
             loop
 
            %%%the alien can move when attacking.  (more of a challenge)
              Ax := Ax + Astep
                if Ax > 630 - radius then
                    Astep := -Astep
                elsif Ax <= 2 then
                    Astep := 2
                end if
%%%When in the wepon loop the man can move and move the wepon
                if hasch then
                    getch (key)
                    if key = "a" or key = "A" then
                        Vx := Vx - 10
                    elsif key = "d" or key = "D" then
                        Vx := Vx + 10
                    elsif key = "w" or key = "W" then
                        Vy := Vy + 10
                    elsif key = "s" or key = "S" then
                        Vy := Vy - 10
                    elsif key = "z" or key = "Z" then
                    end if
                end if
                %%%Vertico%%%
                drawfilloval (Vx, Vy, radius, radius, blue)
                %%%Moster%%%
                drawfilloval (Ax, Ay, radius+10, radius+10, white)
                %%%wepon%%%
                drawfilloval (Vx, By, radius, radius, brightgreen)
                delay (10)
                %%%wepon%%%
                drawfilloval (Vx, By, radius, radius, black)
                %%%Vertico%%%
                drawfilloval (Vx, Vy, radius, radius, black)
                %%%Moster%%%
                drawfilloval (Ax, Ay, radius+10, radius+10, black)
                %%%exit the loop when the wepon gets off the screen
                exit when By > 600
                By := By + 5
                if whatdotcolor  (Vx, By) = white then
                score := score + 1
                end if
                end loop
        end if
        if Vx <= 1 - radius then
        Vx := 1 + radius
        elsif Vx >= 630 then
        Vx := 630 + radius
        end if
        if Vy <= 1 - radius then
        Vy := 1 + radius
        elsif Vy >= 390 then
        Vy := 390 + radius
        end if
    end if
end loop
Sponsor
Sponsor
Sponsor
sponsor
person




PostPosted: Fri Apr 08, 2005 1:13 pm   Post subject: (No subject)

use whatdotcolor for collision detection

and to count how many hits....

use a counter
Vertico




PostPosted: Fri Apr 08, 2005 4:17 pm   Post subject: (No subject)

i understand that. but i dont know how 2 use whatdotcolor. i think i used it wrong for what i need
Bacchus




PostPosted: Sat Apr 09, 2005 1:06 am   Post subject: (No subject)

for this a i think pythagoras is much better that whatdotcolor (btw its used whatdotcolor(x,y:int) and returns the color at that point) cause unless you want to use a lot of checks to check all areas of the circle for that color... no use pythagoras u kno a^2+b^2=c^2 but ill leave more of that for you to figure out Razz
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  [ 4 Posts ]
Jump to:   


Style:  
Search: