Fish aquarium

Post your FreeBASIC source, examples, tips and tricks here. Please don’t post code without including an explanation.
neil
Posts: 594
Joined: Mar 17, 2022 23:26

Re: Fish aquarium

Post by neil »

@BasicCoder2
I like it. It's very nice. <'))))><

Check out this simple fishing derby game.
https://www.youtube.com/watch?v=OWaX-NcK5PQ

You can play fishing derby online.
https://atarionline.org/atari-2600/fishing-derby
BasicCoder2
Posts: 3909
Joined: Jan 01, 2009 7:03
Location: Australia

Re: Fish aquarium

Post by BasicCoder2 »

@neil

So are you interested in writing some computer game?

I played around with bits and pieces required to write computer games but it was more of a puzzle solving exercise then any real outcome. I don't actually play computer games myself.

In my day it was the C64 not the Atari. I did some game like things but used Assembler for speed.

With the fishing derby game I guess you would start by working out the mechanics of the game and adding to it over time. It requires joysticks for two players although I guess a one player version could be made. The sample code below uses the arrow keys.

Code: Select all

screenres 640,480,32
color rgb(0,0,0),rgb(255,255,255):cls

dim as integer x1,y1,x2,y2,x3,y3,fishCount

x1 = 20
y1 = 40
x2 = 40
y2 = 40

x3 = x2
y3 = 180

type FISH
    as integer x
    as integer y
    as integer d
    as integer h  'is a fish hooked or not
end type


dim shared as FISH fsh(0 to 10)

'initialize
for i as integer = 0 to 10
    fsh(i).y = int(rnd(1)*300)+120
    fsh(i).x = int(rnd(1)*630)
    fsh(i).d = int(rnd(1)*2)
    fsh(i).h = -1  'fish not on hook
next i

do
    
    screenlock
    cls
    'draw the water
    line (0,80)-(639,479),rgb(200,200,255),bf
    locate 2,2
    print "FISH COUNT =";fishCount
    
    'draw rod
    line (x1,y1-1)-(x2,y2-1),rgb(0,0,0)
    line (x1,y1)-(x2,y2),rgb(0,0,0)
    line (x1,y1+1)-(x2,y2+1),rgb(0,0,0)
    'draw line
    line (x2-1,y2)-(x3-1,y3),rgb(200,200,0)
    line (x2,y2)-(x3,y3),rgb(200,200,0)
    line (x2+1,y2)-(x3+1,y3),rgb(200,200,0)
    screenunlock
    
    
    if multikey(&h4B) then x2 = x2 - 4
    if multikey(&h4D) then x2 = x2 + 4
    if multikey(&h48) then y3 = y3 - 1
    if multikey(&H50) then y3 = y3 + 1
    
    if x2<60 then x2 = 60
    if x2>x3 then x3 = x3 + 1
    if x2<x3 then x3 = x3 - 1
    if x2<40 then x2 = 40
    if x2>200 then x2 = 200
    if y3<50 then y3=50
    if y3>430 then y3 = 430
    
    'draw fish
    for i as integer = 0 to 10
        if fsh(i).h = -1 then
            if fsh(i).d = 0 then
                draw string (fsh(i).x+7,fsh(i).y-3),"<",rgb(0,0,0)
            else
                draw string (fsh(i).x-11,fsh(i).y-3),">",rgb(0,0,0)
            end if
            circle (fsh(i).x,fsh(i).y),5,rgb(0,0,0),,,,f
        else
            if fsh(i).d = 0 then
                draw string (x3+7,y3-3),"<",rgb(0,0,0)
            else
                draw string (x3-11,y3-3),">",rgb(0,0,0)
            end if
            circle (x3,y3),5,rgb(0,0,0),,,,f  'on hook
        end if
    next i
    
    'move fish
    for i as integer = 0 to 10
        if fsh(i).d = 0 then
            fsh(i).x = fsh(i).x - 1
        else
            fsh(i).x = fsh(i).x + 1
        end if
        if fsh(i).x < 0 then
            fsh(i).x = 630
            fsh(i).y = int(rnd(1)*300)+120
        end if
        if fsh(i).x > 630 then
            fsh(i).x = 0
            fsh(i).y = int(rnd(1)*300)+120
        end if
    next i
    
    'did we hook a fish?
    for i as integer = 0 to 10

        if fsh(i).x > x3-5 and fsh(i).x < x3+5 then
            if fsh(i).y > y3-5 and fsh(i).y < y3+5 then
                fsh(i).h = i 'hooked
            end if
        end if
        
        'unhook fish
        if fsh(i).h <> -1 and y3 < 55 then
            fsh(i).y = int(rnd(1)*300)+120
            fsh(i).x = int(rnd(1)*630)
            fsh(i).d = int(rnd(1)*2)
            fsh(i).h = -1  'fish not on hook
            fishCount = fishCount + 1
        end if
        
    next i
        
    sleep 2
loop until multikey(&H01)

oyster
Posts: 274
Joined: Oct 11, 2005 10:46

Re: Fish aquarium

Post by oyster »

neil
Posts: 594
Joined: Mar 17, 2022 23:26

Re: Fish aquarium

Post by neil »

@BasicCoder2
That's a nice start to a fishing derby game. I just barely said to check it out, and you got a good start on a working version where you can catch fish. That's really impressive.

I am working on a game right now that's going to be a Moonlander-type game. I am drawing a spacecraft right now. I already have the math algorithm done. I will post something in a couple of days.
Post Reply