Scroll Demo

Just BASIC Games
Post Reply
Rod
Site Admin
Posts: 29
Joined: Sat Feb 26, 2005 9:22 pm
Location: Scotland

Scroll Demo

Post by Rod »

This is a short demo of one way to scroll a background in Just BASIC. It is in response to a board question. However if you are keen on games do yourself a favour and spend the small amount of money needed to purchase Liberty BASIC. It is far mour powerfull and has more sprite commands to ease game building.
Attachments
OceanScroller.zip
(690.05 KiB) Downloaded 466 times
Rod
Site Admin
Posts: 29
Joined: Sat Feb 26, 2005 9:22 pm
Location: Scotland

Post by Rod »

I have just tested this at 800x600 and there is a white flash on the left of the screen. This is because getbmp needs to see all of the bmp to grab it It needs more carefull drawing and slicing at the start of the program to eliminate this. I run at a higher resolution normally.
brahn
Posts: 27
Joined: Fri Aug 26, 2005 2:54 pm
Location: Moberly, MO
Contact:

Post by brahn »

Here is the altered code for oceans. Sorry about all the confusion Rod, but making this program run with jb really helped me learn alot in the graphics department. And, thanks for the permission also. It would make a great screen saver!

Code: Select all

    'set up a full screen window at the current resolution with no borders
    nomainwin
    true=1
    false=0
    WindowWidth  = DisplayWidth
    WindowHeight = DisplayHeight
    UpperLeftX = int((DisplayWidth-WindowWidth)/2)
    UpperLeftY = int((DisplayHeight-WindowHeight)/2)
    graphicbox #1.g,0,0,DisplayWidth,DisplayHeight
    button #1, "Exit", [quit], LR, 50, 10
    open "Easter Island" for graphics_nsb as #1
    print #1, "trapclose [quit]"

    'load the sprite images and small background .bmp whicj will be stretched to full screen
    loadbmp "ocean","ocean.bmp"
    loadbmp "g1","g1.bmp"
    loadbmp "g2","g2.bmp"
    loadbmp "g3","g3.bmp"
    loadbmp "g4","g4.bmp"
    loadbmp "g5","g5.bmp"
    print #1.g, "addsprite gull g1 g2 g3 g4 g5 g4 g3 g2";
    print #1.g, "cyclesprite gull 1";
    print #1.g, "background ocean";
    x= DisplayWidth+1

    'now start a timed loop animation that is called every 56 milliseconds
    timer 100, [animation]
    wait

    [animation]

    ' check the keyboard and event list with scan to see if a key or button has been pressed
    scan

    ' now draw the seagull sprite if we start a new one the start pos and size are random
    if x>DisplayWidth then
    x=50
    y=int(rnd(1)*DisplayHeigth)+50
    size=int(rnd(1)*200)+30
    print #1.g, "spritescale gull ";size
    end if
    x=x+10
    print #1.g, "spritexy gull ";x;" ";y
    print #1.g, "drawsprites";

    'play some sound in sync with the animation sometimes play music
    if time$("seconds") > wavecounter+8 then
        musiccounter=musiccounter+1
        if music=false then
            playwave "wave.wav",async
        end if
        wavecounter=time$("seconds")
    end if
    if musiccounter>(rnd(0)*6)+4 then
        musiccounter=0
        goto [song]
    end if
    wait

[song]
    if musiccounter=0 then
        playwave ""
        music=false
        wavecounter=0
    else
        playwave ""
        song=rnd(1)
        select case
            case song<.5
                playwave "yellowbird.wav",loop

        end select
        music=true
     end if
     wait

 [quit]
    playwave ""
    close #1
    end
Post Reply