Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
counter
Author Message
TrAnCeIn4LiFe

Posted: Sun Jun 13, 2004 11:55 am   Post subject: counter

anybody know what is wrong with my life counter it wont take lfie away when it touches the enmy.. then when it reaches zero on x axis

 code: var exr, eyt, xre, xle, yte, ybe : int := 0     % local variable for enemy     %/%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     %  Randomize Enemy's and Location    %     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\%     randint (eyt, 0, maxx)     for decreasing x : maxy .. 1         exr += +xre + xle     % x postion of enemy         eyt += +yte + ybe     % y postion of enemy         randomize         randint (num, 1, 4)     % randomizes 4 enemys to be displayed on the screen         Pic.Draw (sprite3 (num), eyt, exr + x, picMerge)     % draws the random enemy on the screen     end for     %/%%%%%%%%%%%%%%%%%%     %  Life Counter    %     %%%%%%%%%%%%%%%%%%\%     % bxr += +xl + xr     % byt += +yb + yt     % exr += +xre + xle     % eyt += +yte + ybe     if (xl = xle) and (xr = xre) and (yb = ybe) and (yt = yte) then         planelife := planelife - 1     % subtracts 1 life if the enemy touches you     end if                 bxr += +xl + xr     % x position of plane                 byt += +yb + yt     % y position of plane         %/%%%%%%%%%%%%%%%%%         %  Clear Modes    %         %%%%%%%%%%%%%%%%%\%         xl := 0         xr := 0         yt := 0         yb := 0

Bizarro

Posted: Sun Jun 13, 2004 12:04 pm   Post subject: (No subject)

Try this

if (xl>xbe) and (xr >= yte) then
planelife := planelife - 1

if (xl = xle) and (xr = xre) and (yb = ybe) and (yt = yte) then
planelife := planelife - 1

Tony

Posted: Sun Jun 13, 2004 12:19 pm   Post subject: (No subject)

you seem to be checking for the collision outside of your loop
Tony's programming blog. DWITE - a programming contest.
TrAnCeIn4LiFe

Posted: Sun Jun 13, 2004 1:25 pm   Post subject: (No subject)

hum i cant move them inside the loop with other stuf....
this is what i got

 code: process enemy     var exr, eyt, xre, xle, yte, ybe : int := 0     % local variable for enemy     %/%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     %  Randomize Enemy's and Location    %     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\%     randint (eyt, 0, maxx)     for decreasing x : maxy .. 1         exr += +xre + xle     % x postion of enemy         eyt += +yte + ybe     % y postion of enemy         randomize         randint (num, 1, 4)     % randomizes 4 enemys to be displayed on the screen         Pic.Draw (sprite3 (num), eyt, exr + x, picMerge)     % draws the random enemy on the screen     end for     %/%%%%%%%%%%%%%%%%%%     %  Score Counter   %     %%%%%%%%%%%%%%%%%%\%     if (xre = 0 and xle = 0) then         plane_count := plane_count + 50     % for every plane to reach 0 adds 50 points to final score     end if     %/%%%%%%%%%%%%%%%%%%     %  Life Counter    %     %%%%%%%%%%%%%%%%%%\%     % bxr += +xl + xr     % byt += +yb + yt     % exr += +xre + xle     % eyt += +yte + ybe     if (xl = xle) and (xr = xre) and (yb = ybe) and (yt = yte) then         planelife := planelife - 1     % subtracts 1 life if the enemy touches you     end if     %/%%%%%%%%%%%%%%%%%%%%     %  Draw Life Bars    %     %%%%%%%%%%%%%%%%%%%%\% for different amount of life you have     loop         if planelife = 5 then             Pic.Draw (sprite1 (1), 0, 160, picMerge)         elsif planelife = 4 then             Pic.Draw (sprite1 (2), 0, 160, picMerge)         elsif planelife = 3 then             Pic.Draw (sprite1 (3), 0, 160, picMerge)         elsif planelife = 2 then             Pic.Draw (sprite1 (4), 0, 160, picMerge)         elsif planelife = 1 then             Pic.Draw (sprite1 (5), 0, 160, picMerge)         else             endin         end if     end loop end enemy procedure fly     View.Set ("offscreenonly,nobuttonbar")     setscreen ("graphics:maxx;maxy,noecho,nocursor")     %/%%%%%%%%%%%%%%%%%%%%%%%%%%     %  Input Keys For Plane    %     %%%%%%%%%%%%%%%%%%%%%%%%%%\%     loop         Input.KeyDown (chars)         if chars (KEY_UP_ARROW) then             for x : 1 .. 1                 xx (x) := x                 yt := 8             end for         elsif chars (KEY_RIGHT_ARROW) then             for x : 1 .. 1                 xx (x) := 2                 xr := 8             end for         elsif chars (KEY_DOWN_ARROW) then             for x : 1 .. 1                 xx (x) := x                 yb := yb - 8             end for         elsif chars (KEY_LEFT_ARROW) then             for x : 1 .. 1                 xx (x) := x + 2                 xl := xl - 8             end for         end if         %/%%%%%%%%%%%%%%%%%%%         %  Move Airplane    %         %%%%%%%%%%%%%%%%%%%\%         if xx (1) > 0 then             for x : 1 .. 1                 bxr += +xl + xr     % x position of plane                 byt += +yb + yt     % y position of plane                 Pic.Draw (background, 0, 0, picCopy)                 Pic.Draw (sprite1 (1), 0, 160, picMerge)                 Pic.Draw (sprite (xx (x)), bxr, byt, picMerge)                 Draw.Text ("S C O R E :", 5, 370, font, black)     % draws score bar                 Font.Draw (intstr (plane_count), 70, 370, font, black)     % converts score to string so it can aplly font             end for             View.Update         end if         %/%%%%%%%%%%%%%%%%%         %  Boundries      %         %%%%%%%%%%%%%%%%%\%         for x : 1 .. 1             if byt >= maxy then                 byt := maxy - 15                 Pic.Draw (sprite (x), xr, xl, picMerge)             elsif byt = -40 then                 byt := 40                 Pic.Draw (sprite (x), xr, xl, picMerge)             elsif bxr >= maxx then                 bxr := maxx - 80                 Pic.Draw (sprite (x), yb, yt, picMerge)             elsif bxr = -40 then                 bxr := 40                 Pic.Draw (sprite (x), yb, yt, picMerge)             end if         end for         %/%%%%%%%%%%%%%%%%%         %  Clear Modes    %         %%%%%%%%%%%%%%%%%\%         xl := 0         xr := 0         yt := 0         yb := 0         fork enemy     end loop end fly
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 4 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: