REM Chistmas Game - DBC Challenge REM Ashingda27 sync on sync rate 0 randomize timer() gosub Setup hide mouse gosub Restart do if Life < 1 cls ink rgb(255,255,25),0 center text 320,240,"Game Over" center text 320,270,"Score : "+str$(Score) center text 320,400,"Click Mouse to Restart" if mouseclick() > 0 then gosub Restart else gosub Spawn gosub Cannon gosub SnowMan gosub Score paste image 10,0,420,1 endif ink 0,0 text 0,0,"Life Points: "+str$(Life) text 320,0,"Score: "+str$(Score) sync loop Restart: Life = 10 Score = 0 for lp = 0 to 50 SnowMan(lp,0) = 0 Shot(lp,0) = 0 next lp return Spawn: count = count + 1 if count > r for lp = 0 to 50 if SnowMan(lp,0) = 0 SnowMan(lp,0) = 1 SnowMan(lp,2) = 0 SnowMan(lp,1) = rnd(11000) SnowMan(lp,3) = 260 count = 0 r = rnd(5)+1 lp = 50 endif next lp endif return Cannon: mx = mousex() my = 0 mc = mouseclick() if mx <> mxo or my <> myo then shoot = 1 else shoot = 0 mxo = mx myo = my b = atanfull(0-mx,420-my) if b > 0 then b = 0 if b < -45 then b = -45 zrotate object 1,wrapvalue(b) if count2 < 1000 then count2 = count2 + 1 if count2 > 5 and Shoot = 1 for lp = 0 to MaxBall if Shot(lp,0) = 0 if mx = 0 then mx = 1 Shot(lp,0) = 1 Shot(lp,4) = 170 Shot(lp,1) = sin(b)*Shot(lp,4) Shot(lp,2) = cos(b)*Shot(lp,4) Shot(lp,3) = 20 Shot(lp,5) = 0 lp = MaxBall endif next lp count2 = 0 KeyM = 1 else KeyM = 0 endif for lp = 0 to MaxBall if Shot(lp,0) > 0 Shot(lp,3) = Shot(lp,3) + 8 Shot(lp,5) = Shot(lp,5) + 2 cx = 0 - Shot(lp,1) / abs(100) * Shot(lp,3) cy = (420 - (Shot(lp,2)-Shot(lp,5)) / abs(100) * Shot(lp,3)) paste image 21,cx+3,cy-10,1 if cx > 640 or cy > 480 then Shot(lp,0)=0 if cx < 0 or cy < 0 then Shot(lp,0)=0 endif next lp return SnowMan: for lp = 0 to 50 if SnowMan(lp,0) > 0 if SnowMan(lp,3) = 0 SnowMan(lp,2) = SnowMan(lp,2) + 1 SnowMan(lp,1) = SnowMan(lp,1) + SnowMan(lp,2)/100 endif if SnowMan(lp,3) > 0 SnowMan(lp,3) = SnowMan(lp,3) - 1 endif traveled = SnowMan(lp,1)/20 x = WayPointNode(traveled,0) y = WayPointNode(traveled,1) + SnowMan(lp,3)/10 paste image 100,x-8,y-26,1 if x < 10 then SnowMan(lp,0) = 0 : Life = Life - 1 x1 = x-13 y1 = y-30 x2 = x+8 y2 = y+4 for lp2 = 0 to MaxBall if Shot(lp2,0) > 0 cx = 0 - Shot(lp2,1) / abs(100) * Shot(lp2,3) cy = (420 - (Shot(lp2,2)-Shot(lp2,5)) / abs(100) * Shot(lp2,3)) Check = CheckArea(cx,cy,x1,y1,x2,y2) if Check = 1 SnowMan(lp,0) = 0 Shot(lp2,0) = 0 lp2 = MaxBall Score = Score + 1 endif endif next lp endif next lp return Score: return Setup: REM SnowMan ink rgb(120,100,0),0 line 90,106,110,106 ink rgb(10,10,10),0 FillCircle(100,100,6) FillCircle(100,106,7) FillCircle(100,114,8) ink rgb(255,255,255),0 FillCircle(100,100,5) FillCircle(100,106,6) FillCircle(100,114,7) get image 100,90,95,110,121,1 dim SnowMan(50,3) dim WayPoint(50,1) dim WayPointNode(2000,1) dim c(0) MaxBall = 50 dim Shot(MaxBall,5) cls 0 data 29,639,425,580,431,565,438,552,440,542,438,521,433,497,436,478,447,443 data 453,411,452,388,448,368,445,346,445,330,446,309,448,300,449,282,443,267 data 438,245,431,227,435,216,441,201,444,189,445,152,445,138,442,100,432,61 data 423,30,420,0,420 read iz for lp = 1 to iz read ix read iy WayPoint(lp,0) = ix WayPoint(lp,1) = iy if lp > 1 x1 = WayPoint(lp-1,0) y1 = WayPoint(lp-1,1) x2 = WayPoint(lp,0) y2 = WayPoint(lp,1) DrawLine(x1,y1,x2,y2,0) endif next lp get image 10,0,420,640,480,1 cls REM CannonBall ink rgb(230,230,230),0 FillCircle(100,100,3) get image 21,94,94,106,106,1 cls REM Cannon c = 0 z = 1 for lp = 0 to 20 if c + 23 > 255 then z = -1 c = c + 23*z ink rgb(c,c,c),0 box lp,0,lp,80 next lp get image 20,0,0,20,80,2 autocam off make object plain 1,2,8 position object 1,-39,-22,0 cannonx = object screen x(1) cannony = object screen y(1) texture object 1,20 color backdrop rgb(120,160,215) position camera 0,0,-50 return REM -------------------------------------------------------------- REM Function DrawLine REM -------------------------------------------------------------- Function DrawLine(x1,y1,x2,y2,size) if abs(x2-x1) > abs(y2-y1) then l# = abs(x2-x1) else l# = abs(y2-y1) if l# = 0 then l# = 1 z = size for lp = 1 to l# x = x1 + (x2-x1)/l# * lp y = y1 + (y2-y1)/l# * lp if size = 0 ink rgb(235,235,235),0 box x,y,x,479 ink rgb(10,10,10),0 box x,y,x,y WayPointNode(c(0),0) = x WayPointNode(c(0),1) = y c(0) = c(0) + 1 endif if size = 1 dot x,y endif if size > 1 FillCircle(x,y,size) endif next lp EndFunction REM -------------------------------------------------------------- REM Function FillCircle() REM -------------------------------------------------------------- Function FillCircle(cx,cy,r) sr = r*r for i = 1 to r h = sqrt( sr - i*i ) x1 = cx - i y1 = cy - h x2 = cx + i y2 = cy + h if x1 < 0 then x1 = 0 if y1 < 0 then y1 = 0 if x2 > 639 then x2 = 639 if y2 > 479 then y2 = 479 box x1, y1, x2, y2 next i EndFunction REM -------------------------------------------------------------- REM CheckArea Function REM -------------------------------------------------------------- Function CheckArea(px,py,x1,y1,x2,y2) retval = 0 if px > x1 & px < x2 & py > y1 & py < y2 then retval = 1 EndFunction retval