
-----------------------------------
@DRI@N
Mon May 31, 2004 6:32 pm

Hockey Problem...still
-----------------------------------
For god sakes this aint workin ..if  I shoot from somewhere on the right side of the screen it goes down...BUT Y always returns positive

(get puck and press shift to shoot)


setscreen("graphics:800;800")
View.Set("offscreenonly")   
 
colorback(black)
cls

    var crowd_colour:int
    
    var x1_crowd: int
    var y1_crowd: int

    
    var counter:int:=0
    var arena_x : array 1..8 of int := init (200, 200, 250, 550, 
                                   600, 600, 550, 250)
    var arena_y : array 1..8 of int := init (150, 650, 700, 700,
                                   650, 150, 100, 100)
    var Score_font:int:=Font.New ("Garamond:30")
    
    var score:int:=0
    var player_score:string:=""
    var puckx,pucky:int:=400
    var puckychange,puckxchange:int:=1
    var RD_X:int:=500
    var RD_Y:int:=200
    var chars : array char of boolean
      
    var cur_x,cur_y:int
    var totalspeed:int:=2
    
procedure Arena
loop

counter:=counter+1


randint(crowd_colour,1,255)

randint(x1_crowd,1,800)
randint(y1_crowd,1,800)

drawfilloval(x1_crowd,y1_crowd,2,2,crowd_colour)

exit when counter=30000

end loop
end Arena




function X_Velocity_Calculate(px:int,py:int):real
var xvelocity, yvelocity : real 
var angle : real 
var ylength : int 
var xlength : int 


xlength := 400-px
ylength := 620-py

if ylength = 0 then       
angle := 0 

else
    angle := arctand (ylength/xlength) 
end if    
xvelocity := totalspeed*cosd(angle) 

if puckx>400 then
xvelocity := xvelocity *-1
 
end if

result xvelocity
end X_Velocity_Calculate

function Y_Velocity_Calculate(px:int,py:int):real
var xvelocity, yvelocity : real 
var angle : real 
var ylength : int 
var xlength : int 

xlength := 400-px
ylength := 620-py

if ylength = 0 then       
angle := 0 
else 
    angle := arctand (ylength/xlength) 
end if 

yvelocity := totalspeed*sind(angle)
result yvelocity
end Y_Velocity_Calculate


function Collision(x:real,y:real,xwall1:int,xwall2:int,ywall1:int,ywall2:int):boolean
if x < xwall2 and x >xwall1 and y > ywall2 and y =puckx then
puckxchange:=puckxchange*-1
puckychange:=puckychange*-1
end if

if puckx>550 and pucky>650 and (1250-pucky)650 and (1250-RD_Y+32)380 and cur_x 600 and cur_y 