Someone mentioned a onekey challenge a while ago...

Discuss whatever you want here--both QB and non-QB related. Anything from the DEF INT command to the meaning of life!

Moderators: Pete, Mods

Post Reply
m2j

Someone mentioned a onekey challenge a while ago...

Post by m2j »

I dunno if they were serious, or if it's on somewhere else, but Here's something I came up with. FB code.

Code: Select all

'$include: 'scancodes.bi'

defsng a-z
Declare Sub Bang(a,B)
Declare Sub Explode(a,B)
Declare Sub Win
Declare Sub Die
Declare Sub Endscreen
Declare Sub Title

randomize timer

dim shared cloudX(10), CloudY(10), CloudXAcc(10)

dim shared shootsX(10),shootsY(10),shootsXAcc(10),shootsYACC(10)   'parachutes
dim shared bombsX(10),bombsY(10),bombsXACC(10),bombsYACC(10)

dim shared planesX(10),planesY(10),planesYAcc(10),planesEng(10),PlanesXAcc(10)
dim shared gplanesX(10),gplanesY(10),gplanesYAcc(10),gplanesEng(10),gPlanesXAcc(10) 'good planes
dim shared tanksX(10), tanksXAcc(10)
dim shared footX(10), footXAcc(10)

dim shared Score, Length!, Hp

work = 0:Visual = 1

Ang = 0: AngAcc = 0

BulletX = 0:BulletY = 480
BulletXAcc = 0:BullerYAcc = 0

Score = 0100

Hp = 25

Title

for i = 0 to 10
    CloudX(i) = int(rnd*640)
    CloudY(i) = int(rnd*300)
    CloudXAcc(i) = int(rnd*5)+1
    
    TanksX(i) = 640:TanksXAcc(i)=0
    FootX(i) = 645:FootXACc(i) = 0
    
    PlanesX(i) = 700: PlanesXAcc(i) = 0'-int(rnd*15)
    PlanesY(i) = 100+int(rnd*100): PlanesYAcc(i) = 0'10
    
    gPlanesX(i) = -50: gPlanesXAcc(i) = 0'-int(rnd*15)
    gPlanesY(i) = 100+int(rnd*100): gPlanesYAcc(i) = 0'10
    
    shootsX(i)=700:ShootsY(i)=480:ShootsXACC(i) = 0:ShootsYACC(i)=0
    BombsX(i)=700:BombsY(i)=480:BombsXACC(i) = 0:BombsYACC(i)=0
next i

screen 18,,2,1
screenset work,visual

do: if multikey(SC_ESCAPE) then exit do
    A$ = right$(ucase$(inkey$),1)

    if Ang = 0 and A$ = "M" then AngAcc = .18'.15
    if Ang > 0 and A$ = "M" and BulletXACC = 0 then 
        BulletXAcc = Cos(Ang)*10:BulletYAcc = -Sin(Ang)*10
        BulletX = Cos(Ang)*40
        BulletY = 400-(Sin(Ang)*40)
        'do until not multikey(SC_M):loop
    end if
      
    'line (0,400)-(640,480),15,bf
    
    if Hp < 0 then Die
    if timer > Length! then Win
    
    if moved! < timer then
        swap work,Visual
        Screenset Work,Visual
    
        line (0, 0)-(640,400),9,bf
        line (0, 400)-(640,480),2,bf
        line (0,400)-(0+(cos(Ang)*40),400-(sin(Ang)*40)), 15
        'circle (BulletX,BulletY), 10, 15
        Circle (BulletX,BulletY),10,0,,,2/5
        paint (BulletX,BulletY),0
        
        for i = 0 to 10
            line (PlanesX(i), planesY(i))-step(-50,10),7
            line (PlanesX(i), planesY(i))-step(0,10),7
            line (PlanesX(i), planesY(i)+10)-step(-50,0),7
            paint(PlanesX(i)-1, planesY(i)+5),7
            
            line (gPlanesX(i), gplanesY(i))-step(50,10),15
            line (gPlanesX(i), gplanesY(i))-step(0,10),15
            line (gPlanesX(i), gplanesY(i)+10)-step(50,0),15
            paint(gPlanesX(i)+1, gplanesY(i)+5),15
            
            Circle (shootsX(i),ShootsY(i)),15,15,-.0001,-3.14
            Circle (shootsX(i),ShootsY(i)+10),4,15
            Line (shootsX(i),shootsY(i)+14)-step(0,5),15
            line (shootsX(i),shootsY(i)+20)-step(-5,6),15
            line (shootsX(i),shootsY(i)+20)-step(5,6),15
            
            Circle (bombsX(i),bombsY(i)),15,0,-.0001,-3.14
            Circle (bombsX(i),bombsY(i)+12),10,0,,,2/5
            paint (bombsX(i),bombsY(i)+12),0
        next i
        
        for i = 0 to 10
            for j = 0 to 25
                Circle(CloudX(i),CloudY(i)),j,15
                Circle(CloudX(i)+1,CloudY(i)),j,15
            next j
            for j = 0 to 15
                Circle(CloudX(i)+20,CloudY(i)),j,15
                Circle(CloudX(i)+21,CloudY(i)),j,15
            next j
            for j = 0 to 20
                Circle(CloudX(i)-20,CloudY(i)),j,15
                Circle(CloudX(i)-21,CloudY(i)),j,15
            next j
            
            line (TanksX(i)+10,390)-step(30,10),7,bf
            line (TanksX(i),395)-step(50,5),8,bf
            line (TanksX(i),390)-step(25,0),0
            
            Circle (footX(i),385),4,15
            Line (footX(i),389)-step(0,5),15
            line (FootX(i),394)-step(-5,6),15
            line (FootX(i),394)-step(5,6),15
        next i
        
        locate 1,1:print using "Score: ###"; Score:Print using "HQ Hp: ###"; Hp
        print using "Time Left: ###";Length - Timer
        'for i = 0 to 10
        '    print PlanesX(i);PlanesxACC(i),
        '    print TanksX(i);TanksxACC(i),
        '    print gPlanesX(i);gPlanesxACC(i),
        '    print FootX(i);FootxACC(i)
        'next i
                
        Ang = Ang + AngAcc
        
        BulletX = BulletX + BulletXACC
        BulletY = BulletY + BulletYACC
        
        BulletYAcc = BulletYAcc + .2
        
        if Ang > 0 then AngAcc = AngAcc - .01
        if Ang < 0 then Ang = 0:AngAcc = 0

        for i = 0 to 10
            CloudX(i) = CloudX(i) + CloudXAcc(i)
            if CloudX(i) > 640 then CloudX(i) = 0
            
            TanksX(i) = TanksX(i) + TanksXAcc(i)
            if TanksX(i) = 0 then Hp = Hp - 20
            
            FootX(i) = FootX(i) + FootXAcc(i)
            if FOOTX(i) = 0 then Hp = Hp - 5
            
            'Physics
            ShootsX(i) = ShootsX(i) + shootsXAcc(i)
            ShootsY(i) = ShootsY(i) + shootsYAcc(i)
            ShootsYACC(i) = ShootsYACC(i) + .1
            ShootsXACC(i) = ShootsXACC(i) / 2
            
            BombsX(i) = BombsX(i) + BombsXAcc(i)
            BombsY(i) = BombsY(i) + BombsYAcc(i)
            BombsYACC(i) = BombsYACC(i) + .1
            BombsXACC(i) = BombsXACC(i) / 2
            
            PlanesX(i) = PlanesX(i) + PlanesXACC(i)
            PlanesY(i) = PlanesY(i) + PlanesYACC(i)
            PlanesYACC(i) = PlanesYACC(i) - .3
            
            gPlanesX(i) = gPlanesX(i) + gPlanesXACC(i)
            gPlanesY(i) = gPlanesY(i) + gPlanesYACC(i)
            gPlanesYACC(i) = gPlanesYACC(i) - .3

            'Bullet Collsion
            if BulletX > TanksX(i) and BulletX < TanksX(i) + 50 then
                if BulletY > 390 then 
                    Explode TanksX(i)+25, 400
                    Bang TanksX(i)+25, 400:
                    TanksXACC(i) = 0:TanksX(i) = 640
                    Score = Score + 50
                end if
            end if
            if BulletX > FootX(i)-20 and BulletX < FootX(i) + 20 then
                if BulletY > 390 then 
                    Explode FootX(i), 400
                    Bang FootX(i), 400:
                    FootXACC(i) = 0:FootX(i) = 645
                    Score = Score + 15
                end if
            end if
            if BulletX > planesX(i) -50 and BulletX < planesX(i) then
                if BulletY > planesY(i) and BulletY < planesY(i) + 10 then 
                    Explode PlanesX(i)-25, PlanesY(i)
                    Bang PlanesX(i)-25, PlanesY(i)
                    PlanesXACC(i) = 0:PlanesX(i) = 700
                    
                    BulletX =0:BulletY=480
                    BulletXACC = 0:BulletYACC = 0
                    Score = Score + 65
                end if
            end if
            if BulletX > gplanesX(i) and BulletX < gplanesX(i)+50 then
                if BulletY > gplanesY(i) and BulletY < gplanesY(i) + 10 then 
                    Explode gPlanesX(i)+25, gPlanesY(i)
                    Bang gPlanesX(i)+25, gPlanesY(i)
                    gPlanesXACC(i) = 0:gPlanesX(i) = -50
                    
                    BulletX =0:BulletY=480
                    BulletXACC = 0:BulletYACC = 0
                    
                    Score = Score - (Score/4)
                end if
            end if
            if BulletX > shootsX(i)-15 and BulletX < shootsX(i)+15 then
                if BulletY > shootsY(i) and BulletY < shootsY(i) + 20 then 
                    Explode ShootsX(i), ShootsY(i)
                    Bang ShootsX(i), ShootsY(i)
                    ShootsXACC(i) = 0:ShootsX(i) = 700:ShootsY(i)=480:ShootsYACC(i)=0
                    BulletX =0:BulletY=480
                    BulletXACC = 0:BulletYACC = 0
                    
                    Score = Score + 55
                end if
            end if
            if BulletX > bombsX(i)-15 and BulletX < bombsX(i)+15 then
                if BulletY > bombsY(i)-15 and BulletY < bombsY(i) + 30 then 
                    Explode bombsX(i), bombsY(i)
                    Bang bombsX(i), bombsY(i)
                    BombsXACC(i) = 0:bombsX(i) = 700:bombsY(i)=480:bombsYACC(i)=0
                    BulletX =0:BulletY=480
                    BulletXACC = 0:BulletYACC = 0
                    
                    Score = Score - (Score/6)
                end if
            end if

            'Bomb mid-air Collsions
            for j = 0 to 10
                if BombsX(j) > TanksX(i) and BombsX(j) < TanksX(i) + 50 then
                    if BombsY(j) > 380 then 
                        Explode TanksX(i)+25, 400:
                        Bang TanksX(i)+25, 400:
                        TanksXACC(i) = 0:TanksX(i) = 640
                    end if
                end if
                if BombsX(j) > FootX(i)-20 and BombsX(j) < FootX(i) + 20 then
                    if BombsY(j) > 380 then
                        Explode FootX(i), 400
                        Bang FootX(i), 400
                        FootXACC(i) = 0:FootX(i) = 645
                    end if
                end if
                if BombsX(j) > planesX(i) -50 and BombsX(j) < planesX(i) then
                    if BombsY(j) > planesY(i) and BombsY(j) < planesY(i) + 10 then 
                        Explode PlanesX(i)-25, PlanesY(i)
                        Bang PlanesX(i)-25, PlanesY(i)
                        PlanesXACC(i) = 0:PlanesX(i) = 700
                        BombsX(j) =700:BombsY(j)=480
                        BombsXACC(j) = 0:BombsYACC(j) = 0
                    end if
                end if
                if BombsX(j) > gplanesX(i) and BombsX(j) < gplanesX(i)+50 then
                    if BombsY(j) > gplanesY(i) and BombsY(j) < gplanesY(i) + 10 then 
                        Explode gPlanesX(i)+25, gPlanesY(i)
                        Bang gPlanesX(i)+25, gPlanesY(i)
                        gPlanesXACC(i) = 0:gPlanesX(i) = -50
                        BombsX(j) =700:BombsY(j)=480
                        BombsXACC(j) = 0:BombsYACC(j) = 0
                    end if
                end if
            next j

            'Non-explosive landings...
            if shootsY(i) > 390 and shootsX(i)<640 then 
                for j = 0 to 10
                    if FootXAcc(j) = 0 then FootXACC(j) = -1:FootX(j)=ShootsX(i):exit for
                next j
                ShootsY(i) = 480:ShootsX(i)=700:ShootsXACC(i)=0:ShootsYACC(i)=0
            end if
            
            'Explosive Landings...
            if bombsY(i) > 390 and bombsX(i)<640 then
                Explode BombsX(i), BombsY(i)
                Bang BombsX(i), BombsY(i)
                BombsY(i) = 480:BombsX(i)=700:BombsXACC(i)=0:BombsYACC(i)=0
            end if
            if PlanesY(i) > 390 then 
                Explode PlanesX(i)-25, PlanesY(i)
                Bang PlanesX(i)-25, PlanesY(i)
                PlanesXACC(i) = 0:PlanesX(i) = 700
            end if
            if gPlanesY(i) > 390 then 
                Explode gPlanesX(i)+25, gPlanesY(i)
                Bang gPlanesX(i)+25, gPlanesY(i)
                gPlanesXACC(i) = 0:gPlanesX(i) = -50
            end if
            
            'Clipping
            if bombsX(i) > 640 or bombsY(i) < 0 then BombsX(i) = 700:BombsXACC(i) = 0
            if TanksX(i) < 0 then TanksX(i) = 640:TanksXACC(i) = 0
            if FootX(i) < 0 then FootX(i) = 700:FootXACC(i) = 0
            if PlanesX(i) < 0 or PlanesY(i) < 0 then PlanesX(i) = 700:PlanesXACC(i) = 0
            if gPlanesX(i) > 640 or gPlanesY(i) < 0 then gPlanesX(i) = -50:gPlanesXACC(i) = 0
        next i
        
        if (BulletY > 400 and BulletY < 420) or BulletX < 0 then Bang BulletX,BulletY:BulletX = 0:BulletY = 480:BulletXAcc = 0 :BulletYAcc = 0
        
        moved! = timer + .05
        
        if int(rnd*1200)<25 then  'introduce enemy
            for i = 0 to 10
                if TanksX(i) = 640 and TanksXAcc(i) = 0 then 
                    TanksXACC(i) = -int(rnd*3):exit for
                end if
            next i
        end if
        
        if int(rnd*1200)<25 then  'introduce enemy
            for i = 0 to 10
                if planesXAcc(i) = 0 and planesX(i) = 700 then 
                    planesXACC(i) = -int(rnd*15)-10
                    planesYACC(i) = int(rnd*15)
                    planesY(i) = 100+int(rnd*100)
                    exit for
                end if
            next i
        end if
        
        a=int(rnd*10)
        'if int(rnd*1200)<25 and planesXACC(a) <> 0 then    'introduce paratroops
        if planesXACC(a) <> 0 then    'introduce paratroops
            for i = 0 to 10
                if shootsXAcc(i) = 0 and ShootsX(i) = 700 then 
                    shootsXACC(i) = planesXACC(a)-25
                    shootsYACC(i) = 0
                    shootsY(i) = planesY(a)+20
                    shootsX(i) = planesX(a)
                    exit for
                end if
            next i
        end if
        
        if int(rnd*1200)<25 then  'introduce backup
            for i = 0 to 10
                if gplanesXAcc(i) = 0 and gplanesX(i) = -50 then 
                    gplanesX(i) = -50
                    gplanesXACC(i) = int(rnd*15)+10
                    gplanesYACC(i) = int(rnd*15)
                    gplanesY(i) = 100+int(rnd*100)
                    exit for
                end if
            next i
        end if
        
        a=int(rnd*10)
        'if int(rnd*1200)<25 and gplanesXACC(a) <> 0 then    'introduce bombs
        if gplanesXACC(a) <> 0 then    'introduce bombs
            for i = 0 to 10
                if bombsXAcc(i) = 0 and bombsX(i) = 700 then 
                    bombsXACC(i) = gplanesXACC(a)-25
                    bombsYACC(i) = 0
                    bombsY(i) = gplanesY(a)+20
                    bombsX(i) = gplanesX(a)
                    exit for
                end if
            next i
        end if
    end if
    
loop

sub bang(a,b)
    'screenset work,visual
        line (A+25, B+15)-(A-25, B+15),14
        line (A+25, B+15)-(A, B-25),14
        line (A, B-25)-(A-25, B+15),14
        paint (A,B),14
        
        line (A-25, B-15)-(A+25, B-15),14
        line (A-25, B-15)-(A, B+25),14
        line (A, B+25)-(A+25, B-15),14
        paint (A-20, B-10),14
        paint (A+20, B-10),14
        paint (A, B+20),14
        't!= timer +.05:while t!>timer:wend
    'screenset work,visual    
    pcopy work, visual
end sub

sub Explode(a,b)
    for i = 0 to 10
        if a < BombsX(i) +15 and a > BombsX(i) - 15 then
            if b  < BombsY(i) +30 and b > BombsY(i) - 15 then
                Bang BombsX(i), BombsY(i)
                BombsY(i)  = 0:BombsX(i) = 0:BombsYaCC(i) = 0:BombsXACC(i) = 0
            end if
        end if
        if a  < ShootsX(i) +15 and a > ShootsX(i) - 15 then
            if b  < ShootsY(i) +30 and b > ShootsY(i) - 15 then
                Bang ShootsX(i), ShootsY(i)
                ShootsY(i)  = 0:ShootsX(i) = 700:ShootsYaCC(i) = 0:ShootsXACC(i) = 0
            end if
        end if
        
        if a  < FootX(i) +20 and a > FootX(i) - 20 then
            if b  > 380 then
                Bang FootX(i), 395
                FootX(i) = 645:FootXACC(i) = 0
            end if
        end if
        if a  < TanksX(i) +50 and a > TanksX(i) then
            if b  > 380 then
                Bang TanksX(i)+25, 395
                TanksX(i) = 640:TanksXACC(i) = 0
            end if
        end if
        
        if a  < planesX(i) and a > planesX(i) - 50 then
            if b  < PlanesY(i) +10 and b > PlanesY(i) then
                Bang PlanesX(i)-25, PlanesY(i)
                PlanesY(i)  = 0:PlanesX(i) = 700:PlanesYaCC(i) = 0:PlanesXACC(i) = 0
            end if
        end if
        if a  < gplanesX(i) and a > gplanesX(i) + 50 then
            if b  < gPlanesY(i) +10 and b > gPlanesY(i) then
                Bang PlanesX(i)+25, PlanesY(i)
                gPlanesY(i)  = 0:gPlanesX(i) = -50:gPlanesYaCC(i) = 0:gPlanesXACC(i) = 0
            end if
        end if
    next i    
end sub 

Sub Die
    screen 0,,1,1:width 80
    color 15,0
    sleep
    cls
    print "You have failed to defend the Bunker."
    print
    print "If you could only have held out for ";lENGTH;" more seconds..."
    sleep
    endscreen
End sub 

Sub Win
    screen 0,,1,1:width 80
    cls: color 15,0
    cls
    print "Congratulations, you held off the advance long enough for the"
    color 0,15:    print "Amazing Weapon ";:color 15,0
    print "to be deployed."
    print
    print "And have been duly recognised for you exceptionally large score of ";Score;"."
    sleep
    endscreen
End Sub 

sub Endscreen
    cls:color 15,0
    print "Thanks for playing onekey."
    print
    print "Email:  Matt2jones@yahoo.com"
    sleep
    system
end sub

Sub title
    screen 0,,1,1
    color 15,0
    print "Onekey!  - A retared arcade game by Matt2jones"
    print
    print "The enemy are pushing for a final advance.  "
    print "Moral is low, and equipment is lower in goodness"
    print "then the usual way that it is."
    print 
    print "Pressing M will kick the turret of gun towards "
    print "the blue sky.  Prssing M again will launch the"
    print "black bomb."
    
    print
    print "You must hold off the advance until Head Quaters"
    print "are able to launch our new";:color 0,15:print "Amazing Weapon";:color 15,0
    print "and win the war eventually."
    print
    print "Air support will be plentiful, but deadly and insane."
    print 
    Input "How Big a Challeng are you up for having? (Input Time Limit)",Length
    print
    print "GO!"
    
    Length = Length + timer
    
    sleep
End sub
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Post by {Nathan} »

actually, it was only about 2 weeks ago... not that long...

btw, there IS a search function on these forums...
Image
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

Nathan1993 wrote:btw, there IS a search function on these forums...
My board has seach right on the main page ("What is Real" default theme, not the Sub Silver one), and there are many other phpBB Themes with it too (Not on my board, avalible for phpBB :wink: ),. pretty swift if you ask me.. :lol:

:wink:
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
m2j

Post by m2j »

Did any of you play the game or do you just like to complain about the method of my press release :roll:

Come on, a game is a game, the challenge was just an excuse to write one...

or whatever, fork you.

m2j
sid6.7
Veteran
Posts: 318
Joined: Tue Jun 21, 2005 8:51 am
Location: west USA
Contact:

Post by sid6.7 »

m2j wrote:Did any of you play the game or do you just like to complain about the method of my press release :roll:

Come on, a game is a game, the challenge was just an excuse to write one...

or whatever, fork you.

m2j

umm dont hurt me please.. but where is the scancodes.bi file
my qb wants it...
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

sid6.7 wrote:umm dont hurt me please.. but where is the scancodes.bi file
my qb wants it...
It's a FreeBASIC lib.... It doesn't work in QB,.. Niether will the SCREEN 18

I also don't have this lib, but, REMing it out the game still works,. or I think.. pretty interesting none-the-less.... :wink:
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
m2j

Post by m2j »

Shit, sorry, i ment to say:

It's the scancode constants that are listed in the GFXlib documentation... There in some other .bi as well, I just don't remember which...

Just delete the line and replace the SC_ESCAPE with 1 and its fine.

I ment to fix that myself.

sorry.

matt
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

Matt, to follow the rules you nede to make a zip, or rar, with both the bas and exe, as well as all other needed files..
I have left this dump.
m2j

Post by m2j »

Shit, well, I tried, you can't blame me for that...

Guess I'll just sit this one out then :roll:

m2j
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

hehe :P
I have left this dump.
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Post by {Nathan} »

m2j wrote:Shit, well, I tried, you can't blame me for that...

Guess I'll just sit this one out then :roll:

m2j
didnt know you were THAT lazy :-p
Image
Post Reply