Win Screensavers with qbasic ARE possible! Read on...



  • Try this one, it will shoot fireworks across your screen, which fall to the ground and bounce. For slower computers, speed up the program by lowering the Speed value and reducing the FlareCount%. Let me know if it works!

    FlareCount% = 20 ' The number of fragments that separate when
    ' the firework explodes.
    Gravity = 9.8 ' Strength of gravity (9.8 = earth).
    Speed = 8 ' You may need to adjust this according to
    ' speed of your computer - a lower number will
    ' make the program run faster.

    SCREEN 13: CLS
    COLOR INT(RND * 15) + 1
    REDIM SHARED FlareX(FlareCount%), FlareY(FlareCount%)
    REDIM SHARED FlareX.Vel(FlareCount%), FlareY.Vel(FlareCount%)
    FlareX(1) = INT(RND * 320)
    FlareY(1) = 200
    FlareX.Vel(1) = 2 * ((FlareX(1) - 160) / 160)
    FlareY.Vel(1) = 3.5 + (RND * 2.5)
    FOR SetFlares% = 2 TO FlareCount%
    FlareX(SetFlares%) = FlareX(1): FlareY(SetFlares%) = FlareY(1)
    FlareX.Vel(SetFlares%) = FlareX.Vel(1): FlareY.Vel(SetFlares%) = FlareY.Vel(1)
    NEXT SetFlares%
    ExplosionStage% = 0
    IF FlareY.Vel(1) < -.5 AND ExplosionStage% = 0 THEN ExplosionStage% = 1
    FOR DrawFlares% = 1 TO FlareCount%
    PSET (FlareX(DrawFlares%), FlareY(DrawFlares%))
    NEXT DrawFlares%
    FOR DelayLoop = 1 TO 1000 * Speed
    KeyPress$ = INKEY$
    IF KeyPress$ <> "" THEN ExitRequest% = -1
    NEXT DelayLoop
    FOR ClearFlares% = 1 TO FlareCount%
    PSET (FlareX(ClearFlares%), FlareY(ClearFlares%)), 0
    NEXT ClearFlares%
    IF ExplosionStage% = 1 THEN
    FOR Scatter% = 1 TO FlareCount%
    FlareX.Vel(Scatter%) = 2.5 * (RND - .5)
    FlareY.Vel(Scatter%) = RND * 1.5
    NEXT Scatter%
    ExplosionStage% = 2
    END IF
    DeadFlares% = 0
    FOR ResetProjectile% = 1 TO FlareCount%
    FlareX(ResetProjectile%) = FlareX(ResetProjectile%) - FlareX.Vel(ResetProjectile%)
    FlareY(ResetProjectile%) = FlareY(ResetProjectile%) - FlareY.Vel(ResetProjectile%)
    IF FlareY(ResetProjectile%) > 200 THEN
    FlareY(ResetProjectile%) = 200
    FlareY.Vel(ResetProjectile%) = (-FlareY.Vel(ResetProjectile%) / 2)
    END IF
    IF FlareY(ResetProjectile%) > 190 AND ABS(FlareY.Vel(ResetProjectile%)) <= .05 THEN
    DeadFlares% = DeadFlares% + 1
    END IF
    NEXT ResetProjectile%
    FOR GravityEffect% = 1 TO FlareCount%
    FlareY.Vel(GravityEffect%) = FlareY.Vel(GravityEffect%) - (Gravity / 98)
    NEXT GravityEffect%
    LOOP UNTIL ExitRequest% OR DeadFlares% = FlareCount%
    LOOP UNTIL ExitRequest%

    : JIMBO

  • But why spend time looking when you can make your own? Have a look at the 2nd bit of code I posted for FRIEND OF BASIC - That'll give you a few hints as to how to alter your palette, and what to do if your palette's intensities exceed 63.

    Now, as for the matter of creating your own, just have a look at the draw command. Experiment with it some, and see what you can create.

    Draw can go offscreen, so if your designs get complicated, you don't have to worry about everything going sour on you because it draws off the screen, unlike the pset command.

  • : How exactly do you edit binary (non-plain text ASCII) files in QB? I never managed to work that out - do you have any programs that demonstrate how to do this? And how do you read a file past an EOF character? Thanks in advance!
    I don't know how to do that exactly, but with a little extra code, you can kinda do it. Have your input file, and a temp outfile. When the LOC of the infile matches up with the byte data that you want to modify, instead of copying it from the infile, replace the modified data with what would go into the out file, and keep going. After that, close the files, kill your infile, and rename your outfile to the old infile name. If I think of how to do it directly, I'll post. I came close in the code that I wrote, but the byte that should have been at position 5 got replaced by something else. The something else was good, but not what I wanted. I'll give it another go.

    As for the EOF marker, that's there for your protection. Do not try to circumvent it. If you want to place more data into a file, open it as append mode, then keep writing. Append will safely remove the eof marker so you can keep on writing.

    The eof tells the hard disk that the rest of that disc cluster should not have any data written to it. Only one file should occupy a cluster at a time. If you break the eof, you break a ground rule of dos, and it could have unpredictable consequences.

    My little disclaimer over, I'll tell you what you wanted to know. I haven't done disc reading with asm in a long time, so I have no code for you, and what I do have might not be totally accurate, and you can mess stuff up, so don't hold me to this info, ok?

    To read past, you'll have to use assembly, taking into account sectors per cluster, etc, physically locate the file on the disc's surface, goto that head, sector, and cluster, on that particular disc and partition, and begin reading the sectors.
    Writing goes the same way.

    To be safe, use a program that you trust to do the job for you. I'm sure others know how to do what you want far better than myself, so post again, and see if you get what you wanted.

    Best of luck in your programming ventures.


    : JIMBO
    Hey Jimbo,

    All of these examples we've given you uses different ways create graphics. AdamC uses the DRAW statement, which is cool. Me and Alister used PSET. And I used the GET and PUT statements for storing graphics in arrays. There are other statements I think you should look at too. I use PSET, but I could have just as easily used LINE to make the slashes. (probably easier, but oh well) There is also a CIRCLE statement too. Don't settle for just one statement try them all. Oh! LINE can be used to draw boxes on the screen too. You guys have got me going. I'm working on some more QB screensavers. When they're done I'll post them.

  • : How exactly do you edit binary (non-plain text ASCII) files in QB? I never managed to work that out - do you have any programs that demonstrate how to do this? And how do you read a file past an EOF character? Thanks in advance!
    I haven't looked at it, but I think you can open a file for binary input and output with the OPEN statement. I think it works like a random access. I haven't messed around with the binary open yet, but I'm going to read up on it in the help file.
    I think it PUTs a byte at a time.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!