
-----------------------------------
Will910
Thu Jun 17, 2010 9:16 pm

Turing Space shooter game-hit detection and scoring problem
-----------------------------------
What is it you are trying to achieve?



What is the problem you are having?



Describe what you have tried to solve this problem



Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)


What is it you are trying to achieve?
I am trying to get my program to keep track of the score properly(10 points per hit)
and for the hit detection to work properly.


What is the problem you are having?
The score seems to go up randomly when i fire off to the side of cyclops


Describe what you have tried to solve this problem
I have tried if statements that create an imaginary "Box" around the cyclops but I may have messed it up.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)


var x, y, button, buttonupdown : int
var font1, font2, font3, font4 : int
var WinID : int
var lives : int := 0
var points : int := 0
var xcan : int := 0
var num, num1 : int := 0
var yball, xball : int := 0
var lvl : int := 0
var clr, clr1, clr2 : int := 0
var hiscore : int := 0
var code : string
var key : string (1)
var fired : boolean := false
var xc1, xc2, xc3, xc4, xc5, xc6, xc7, xc8, xc9, xc10 : int
var yc1, yc2, yc3, yc4, yc5, yc6, yc7, yc8, yc9, yc10 : int
drawfill (1, 1, 255, 1)
font1 := Font.New ("chiller:32:underline,bold")
font2 := Font.New ("Arial black:24")
font3 := Font.New ("TremorITC TT:32:underline,bold")
font4 := Font.New ("BankGothic Lt BT:32:bold")
Font.Draw ("Beware of the Cyclops", 180, 200, font1, 12)
play ("A>")
cls
xcan := 260
xball := xcan
loop
    %Title Screen
    drawfill (1, 1, 255, 1)
    color (14)
    colorback (255)
    drawbox (200, 370, 440, 320, 12) %start game button
    Font.Draw ("Start", 270, 335, font2, 14)
    drawbox (200, 230, 440, 180, 12) %Instructions button
    Font.Draw ("Instructions", 215, 195, font2, 14)
    drawbox (200, 100, 440, 50, 12) %Exit button
    Font.Draw ("Exit", 275, 65, font2, 14)

    %left cyclops on title screen
    drawfilloval (100, 200, 25, 25, 4)
    drawfilloval (100, 210, 7, 7, 1)
    drawfillarc (100, 190, 15, 10, 180, 0, 0)
    drawfillarc (100, 188, 12, 7, 180, 0, 255)

    %right cyclops on title screen
    drawfilloval (530, 200, 25, 25, 4)
    drawfilloval (530, 210, 7, 7, 1)
    drawfillarc (530, 190, 15, 10, 180, 0, 0)
    drawfillarc (530, 188, 12, 7, 180, 0, 255)
    View.Set ("offscreenonly")
    buttonwait ("down", x, y, button, buttonupdown)
    if x > 200 and x < 440 and y < 230 and y > 180 then
       View.Update
     cls
        drawfill (1, 1, 255, 1)
        drawbox (1, 399, 105, 350, 12)
        locate (2, 2)
        put "Back to menu" ..
        Font.Draw ("Instructions", 180, 325, font4, 9)
        locate (6, 1)
        color (0)
        put "Beware of the cyclops is played using the arrow keys, mouse and space bar. The"
        put "arrow keys control the movement of your cannon," ..
        put " and the spacebar is used to fire the cannon." ..
        put " You collect power ups by   shooting them out of the sky and killing bosses." ..
        put " You also accumulate points for each enemy you shoot down, these " ..
        put " points can be used to upgrade your cannon and to buy different projectiles." ..
        put " After 3 levels of gameplay you will face a boss,  which will be tougher than" ..
        put "regular cyclops, but will give a higher point reward."
        loop
            buttonwait ("down", x, y, button, buttonupdown)
            exit when x > 1 and x < 105 and y > 350 and y < 399
        end loop
        if x > 200 and x < 440 and y < 100 and y > 50 then
            exit
        end if
    elsif x > 200 and x < 440 and y > 320 and y < 370 then
        View.Update
        cls
        %Y co-ordinates for cyclops'
        randint (yc1, 400, 600)
        randint (yc2, 400, 610)
        randint (yc3, 400, 450)
        randint (yc4, 500, 600)
        randint (yc5, 400, 550)
        randint (yc6, 440, 610)
        randint (yc7, 550, 610)
        randint (yc8, 420, 610)
        randint (yc9, 600, 700)
        randint (yc10, 400, 440)

        %X co-ordinates for cyclops'
        randint (xc1, 40, 580)
        randint (xc2, 40, 580)
        randint (xc3, 40, 580)
        randint (xc4, 40, 580)
        randint (xc5, 40, 580)
        randint (xc6, 40, 580)
        randint (xc7, 40, 580)
        randint (xc8, 40, 580)
        randint (xc9, 40, 580)
        randint (xc10, 40, 580)
        randint (clr, 1, 255)
        randint (clr1, 1, 255)
        randint (clr2, 1, 255)
        lives := 10
        loop
            loop
                if yball > 400 and fired = true then
                    fired := false
                    yball := 0
                    xball := xcan
                    num := 0
                end if
                if fired = true and xball >= xc1 - 15 and xball = yc1 - 15 and yball + 5 = xc1 - 15 and xball + 5 = xc2 - 15 and xball = yc2 - 15 and yball + 5 = xc2 - 15 and xball - 5 = xc3 - 15 and xball = yc3 - 15 and yball + 5 = xc3 - 15 and xball - 5 = 200 and x = 180 and y 