Qbasicnews.com
July 05, 2020, 03:23:00 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Angle Shot  (Read 2126 times)
Zack
*/-\*
*****
Posts: 3974



WWW
« on: May 12, 2006, 03:01:33 PM »

A pointless shooting app! :wtnod:
Arrows change turret angle, space fires.
You might have to adjust the delay value at the top if it runs too fast or slow.
Code:
'Angle Shot
'By Zachary Vernon
'Last updated (mm/dd/yy): 05/12/06
#define delay 6000000
#define radConv 0.01745329
#include "fbgfx.bi"
type particle
    x as double
    y as double
    xinc as double
    yinc as double
    l as integer
end type
angle=90
dim as double sinT(0 to 360),cosT(0 to 360)
dim as double radians,tx1,tx2,ty1,ty2
redim b(2) as particle
for i=0 to 360
    radians=radConv*i
    sinT(i)=sin(radians)
    cosT(i)=cos(radians)
next
screenres 320,200
circle (160,200),10,15,,,,f
tx2=160+(cosT(angle)*15)
ty2=200-(sinT(angle)*15)
line (160,200)-(tx2,ty2)
locate 25,1:print "90 degrees";
b(0).l=0
do until multikey(1)
    for i=0 to ubound(b)
        if b(i).l=1 then
            pset (b(i).x,b(i).y),0
            b(i).x+=b(i).xinc
            b(i).y+=b(i).yinc
            pset (b(i).x,b(i).y)
            for n=1 to delay/liveB:next
            if b(i).x<-1 or b(i).y<-1 or b(i).x>320 then
                b(i).l=0
                liveB+=-1
            end if
        end if
    next
    if multikey(SC_LEFT) and angle<160 then angleInc=5
    if multikey(SC_RIGHT) and angle>20 then angleInc=-5
    if angleInc then
        line (160,200)-(tx2,ty2),0
        angle+=angleInc
        tx2=160+(cosT(angle)*15)
        ty2=200-(sinT(angle)*15)
        line (160,200)-(tx2,ty2)
        circle (160,200),10,15,,,,f
        angleInc=0
        locate 25,1
        print "            ";
        locate 25,1
        print ltrim$(str$(angle));" degrees";
    end if
    if multikey(SC_SPACE) then
        pi=ubound(b)
        redim preserve b(pi+1)
        b(pi).l=1
        b(pi).xinc=cosT(angle)*5
        b(pi).yinc=-sinT(angle)*5
        b(pi).x=160+(cosT(angle)*16)
        b(pi).y=200-(sinT(angle)*16)    
        liveB+=1
    end if
    if liveB=0 then
        for i=1 to delay:next
    end if
    if liveB=0 then redim preserve b(1)
    locate 1,1:print"      ";:locate 1,1:print ubound(b);
loop
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
jupiter3888
Member
*
Posts: 63



WWW
« Reply #1 on: May 14, 2006, 12:37:21 AM »

lol, looks funny when you hold don fire and move the turret from side to side.
Logged

url=http://gm2.ath.cx/~jupiter3888]the home of jupiter3888 -> http://gm2.ath.cx/~jupiter3888[/url]
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!