Warning: Undefined variable $mode in /var/www/virtual/qbnz.com/htdocs/highlighter/examples/qbasic/rel-plasma.php on line 6
GeSHi - Generic Syntax Highlighter :: Examples
 
Navigation
Home News Examples Demo Downloads FAQ Documentation Mailing Lists License
Support GeSHi!
If you're using GeSHi, why not help GeSHi out? You can link to GeSHi with this image:
Powered by GeSHi
Get the HTML

Project Status
The latest stable version of GeSHi is 1.0.8.11, released on the 19th of Aug, 2012.

Supported Languages:
*ABAP
*Actionscript
*ADA
*Apache Log
*AppleScript
*APT sources.list
*ASM (m68k)
*ASM (pic16)
*ASM (x86)
*ASM (z80)
*ASP
*AutoIT
*Backus-Naur form
*Bash
*Basic4GL
*BlitzBasic
*Brainfuck
*C
*C for Macs
*C#
*C++
*C++ (with QT)
*CAD DCL
*CadLisp
*CFDG
*CIL / MSIL
*COBOL
*ColdFusion
*CSS
*D
*Delphi
*Diff File Format
*DIV
*DOS
*DOT language
*Eiffel
*Fortran
*FourJ's Genero
*FreeBasic
*GetText
*glSlang
*GML
*gnuplot
*Groovy
*Haskell
*HQ9+
*HTML
*INI (Config Files)
*Inno
*INTERCAL
*IO
*Java
*Java 5
*Javascript
*KiXtart
*KLone C & C++
*LaTeX
*Lisp
*LOLcode
*LotusScript
*LScript
*Lua
*Make
*mIRC
*MXML
*MySQL
*NSIS
*Objective C
*OCaml
*OpenOffice BASIC
*Oracle 8 & 11 SQL
*Pascal
*Perl
*PHP
*Pixel Bender
*PL/SQL
*POV-Ray
*PowerShell
*Progress (OpenEdge ABL)
*Prolog
*ProvideX
*Python
*Q(uick)BASIC
*robots.txt
*Ruby
*Ruby on Rails
*SAS
*Scala
*Scheme
*Scilab
*SDLBasic
*Smalltalk
*Smarty
*SQL
*T-SQL
*TCL
*thinBasic
*TypoScript
*Uno IDL
*VB.NET
*Verilog
*VHDL
*VIM Script
*Visual BASIC
*Visual Fox Pro
*Visual Prolog
*Whitespace
*Winbatch
*Windows Registry Files
*X++
*XML
*Xorg.conf

GeSHi 1.0.8.11 is the current stable release, with eighteen new languages and bug fixes over the last release.

GeSHi 1.1.2alpha5 is the current latest version from the development branch, with full C support (see the GeSHi development website).
Subscribe
RSS 2
Mailing Lists
HomeNewsExamplesDemoDownloadsFAQDocumentationMailing ListsLicense 
5:01 am GMT

Examples

Examples » QBasic/QuickBASIC
'/Water on top of Plasma. :*)
'/Just found out that the more pixels you sample the better the ripple looks.
'/So I sampled 8 instead of just 4.
'/The plasma uses sine additions so no pal rotation is done. :*)
'/This would run inside the Ide but compile for speed.
'/Relsoft My 11,2003
 
DEFINT A-Z
REM $DYNAMIC
 
 
CONST PI = 3.14151693#
CONST Xmax% = 319                   'Viewport dimensions
CONST Ymax% = 199                   'Small means fast
CONST XmaxM1% = Xmax% - 1
CONST YmaxM1% = Ymax% - 1
CONST XmaxP1% = Xmax% + 1
CONST YmaxP1% = Ymax% + 1
 
 
Xm& = Xmax% + 1
Ym& = Ymax% + 1
Xmm& = Xmax%
Size& = ((Xm& * Ym&) \ 2)
DIM Texture%(Size&)
DIM w1%(Size&)
DIM w2%(Size&)
 
DIM Lsin1%(-1024 TO 1024)
DIM Lsin2%(-1024 TO 1024)
DIM Lsin3%(-1024 TO 1024)
DIM Ly&(Ymax%)
 
 
FOR i% = -1024 TO 1024
    Lsin1%(i%) = SIN(i% / (32)) * 128      'Movement to left
    Lsin2%(i%) = SIN(i% / (64)) * 128       'Horiz bands
    Lsin3%(i%) = SIN(i% / (64)) * 128        'Vertical bands
NEXT i%
FOR i% = 0 TO Ymax%
    Ly&(i%) = i% * Xmm&
NEXT i%
 
 
wseg1% = VARSEG(w1%(0))
wseg2% = VARSEG(w2%(0))
woff1& = VARPTR(w1%(0))
woff2& = VARPTR(w2%(0))
 
Tseg% = VARSEG(Texture%(0))
Toff& = VARPTR(Texture%(0))
 
 
 
 
CLS
SCREEN 13
RANDOMIZE TIMER
 
 
FOR i% = 0 TO 255
    OUT &H3C8, i%
    OUT &H3C9, INT(32 - 31 * SIN(i% * PI / 32))
    OUT &H3C9, INT(32 - 31 * SIN(i% * PI / 64))
    OUT &H3C9, INT(32 - 31 * SIN(i% * PI / 128))
NEXT i%
 
Frames& = 0
T# = TIMER
DO
    Frames& = Frames& + 1
    IF Frames& AND 1 THEN
        DEF SEG = wseg1%
        ty% = 2 + INT(RND * YmaxM1% - 3)            'Rain
        tx% = 2 + INT(RND * XmaxM1% - 3)
        IF tx% > 1 AND ty% > 1 AND tx% < XmaxM1% AND ty% < YmaxM1% THEN
            POKE woff1% + Ly&(ty%) + tx%, 255
        END IF
        T! = TIMER                                  'Your finger
        x% = INT(COS(T! * .8) + SIN(T!) * 140)
        y% = INT(SIN(T! + .2) * SIN(T! * .2) * 90)
        xx% = x% + Xmax% \ 2
        yy% = y% + Ymax% \ 2
        IF xx% > 1 AND yy% > 1 AND xx% < XmaxM1% AND yy% < YmaxM1% THEN
            POKE woff1% + Ly&(yy%) + xx%, 255
            POKE woff1% + Ly&(200 - yy%) + (320 - xx%), 255
        END IF
    END IF
 
    GOSUB Plasma
 
    off1& = woff1% + Xmax% + 1
    off2& = woff2% + Xmax% + 1
 
    'Water simulation
    FOR y% = 1 TO YmaxM1%
      FOR x% = 1 TO XmaxM1%
        DEF SEG = wseg1%
        c% = PEEK(off1& + 1) + PEEK(off1& - 1) + PEEK(off1& + Xmax%) + PEEK(off1& - Xmax%)
        c% = c% + PEEK(off1& + XmaxM1%) + PEEK(off1& - XmaxM1%) + PEEK(off1& + XmaxP1%) + PEEK(off1& - XmaxP1%)
        DEF SEG = wseg2%
        c% = (c% \ 4 - PEEK(off2&))
        c% = ABS(c% - c% \ 256)
        POKE off2&, c%
        off1& = off1& + 1
        off2& = off2& + 1
     NEXT x%
        off1& = off1& + 1
        off2& = off2& + 1
    NEXT y%
 
    offs& = 0
    off1& = woff1% + Xmax% + 1
    off2& = woff2% + Xmax% + 1
 
 
    'Refraction
    FOR y% = 1 TO YmaxM1%
      FOR x% = 1 TO XmaxM1%
         DEF SEG = wseg1%
         Xoff% = PEEK(off1& - 1) - PEEK(off1& + 1)
         Yoff% = PEEK(off1& - Xmax%) - PEEK(off1& + Xmax%)
         xt% = x% + Yoff% \ 4
         yt% = y% + Xoff% \ 4
         IF xt% > 0 AND yt% > 0 AND xt% < Xmax% AND yt% < Ymax% THEN
             DEF SEG = Tseg%
             c% = PEEK(Ly&(yt%) + xt% + Toff&)
         ELSE
            c% = 0
         END IF
         DEF SEG = &HA000
         POKE offs& + x%, c%
         off1& = off1& + 1
     NEXT x%
        offs& = offs& + 320
        off1& = off1& + 1
    NEXT y%
        SWAP wseg1%, wseg2%                 'Magic
 
LOOP UNTIL INKEY$ <> ""
 
DEF SEG
CLS
SCREEN 0
WIDTH 80
PRINT "FPS:"; Frames& / (TIMER - T#)
PRINT "Water on Plasma by Relsoft"
c$ = INPUT$(1)
 
END
 
 
Plasma:
    DEF SEG = Tseg%
    Ptr& = Toff&
    counter& = (counter& + 1) AND &H7FFFFFFF
    FOR y% = 0 TO Ymax%
        yy% = (y% + counter&) AND 1023
        FOR x% = 0 TO Xmax%
            xx% = (x% + counter&) AND 1023
            c% = Lsin3%(x% + y%) + Lsin1%(xx%) + Lsin2%(yy%)
            POKE Ptr& + x%, c%
        NEXT x%
            Ptr& = Ptr& + Xmax%
    NEXT y%
 
RETURN  

This category contains 2 examples, and has been viewed 30527 times.

  • Plasma - An example of Plasma in QuickBASIC by Relsoft (9122 views)
  • Dangerous Example - A simple QBasic example (7724 views)