Author Topic: 2D Scroll and sine dots.  (Read 622 times)

0 Members and 1 Guest are viewing this topic.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 16781
  • Karma: 439
  • evil/good
    • View Profile
    • My Homepage
2D Scroll and sine dots.
« on: February 28, 2007 »


This is a very simple program just showing how to make a parallax starfield and some dots :)
Nothing else to type about this one really.

Code: [Select]
; 2D Drawing Test By Nick Simpson
; Open A Windowed Screen For Graphic Output And Wait For Escape
; To Be Pressed Before Closing.
;
;===============================================================================

;===========================
; Open A screen For Drawing;
;===========================
Global  starnum.w,xres.w,yres.w,dxx.f,dyy.f
starnum = 1000
xres=640
yres=480

Dim starx.w(starnum)
Dim stary.w(starnum)
Dim stars.b(starnum)

For a=1 To starnum

  starx(a)=Random(xres-4)+2
  stary(a)=Random(yres-4)+2
  stars(a)=(Random(4))+1
 
Next

InitSprite()
window= OpenScreen(xres,yres,32,"(C) NICK SIMPSON 2005")


InitKeyboard()

; Main Loop Begins;
;=============================================================================
Repeat
    StartDrawing(ScreenOutput())
     
     
      For a=1 To starnum
      If starx(a)<xres-1 And starx(a)>1
        If stars(a)=1
        Plot (starx(a),stary(a),$505050)
        Plot (starx(a)-1,stary(a),$303030)
        Plot (starx(a)+1,stary(a),$303030)
        Plot (starx(a),stary(a)-1,$303030)
        Plot (starx(a),stary(a)+1,$303030)
        ElseIf stars(a)=2
        Plot (starx(a),stary(a),$808080)
        Plot (starx(a)-1,stary(a),$303030)
        Plot (starx(a)+1,stary(a),$303030)
        Plot (starx(a),stary(a)-1,$303030)
        Plot (starx(a),stary(a)+1,$303030)
       
        ElseIf stars(a)=3
        Plot (starx(a),stary(a),$a0a0a0)
        Plot (starx(a)-1,stary(a),$303030)
        Plot (starx(a)+1,stary(a),$303030)
        Plot (starx(a),stary(a)-1,$303030)
        Plot (starx(a),stary(a)+1,$303030)
       
        ElseIf stars(a)=4
        Plot (starx(a),stary(a),$c0c0c0)
        Plot (starx(a)-1,stary(a),$303030)
        Plot (starx(a)+1,stary(a),$303030)
        Plot (starx(a),stary(a)-1,$303030)
        Plot (starx(a),stary(a)+1,$303030)
       
        ElseIf stars(a)=5
        Plot (starx(a),stary(a),$e0e0e0)
        Plot (starx(a)-1,stary(a),$303030)
        Plot (starx(a)+1,stary(a),$303030)
        Plot (starx(a),stary(a)-1,$303030)
        Plot (starx(a),stary(a)+1,$303030)
       
        EndIf
       
     
    EndIf       
   
        starx(a)=starx(a)+stars(a)
        If starx(a)>xres-2
        starx(a)=starx(a)-xres
        EndIf
       
      Next

   For l=1 To 7200
    argee=RGB(100+99*Sin(l+m),100+99*Sin(l+m/2),100+99*Sin(l+m/4))
    dxx=320+(300*Sin((l+m)/102))
    dyy=240+(200*Cos((l+n)/100))
    Plot (dxx,dyy,argee)
    Plot (dxx-1,dyy,argee)
    Plot (dxx+1,dyy,argee)
    Plot (dxx,dyy-1,argee)
    Plot (dxx,dyy+1,argee)
   Next
   m=m+1
   n=n-2
   

      DrawingMode(1)
      FrontColor(255,255,255)
     
      Locate (120+(10*Sin(m/5)),220)
      DrawText("This Should Render Text To The Screen! Press Escape To Exit")
     
     
    StopDrawing()
; Swap The Screen Buffers;
  FlipBuffers()
    ClearScreen(0,0,0)
; Test The Keyboard;
  ExamineKeyboard()

Until KeyboardPushed (#PB_Key_Escape)
; Main Loop Ended;
;=============================================================================

; Stop Program;
End

Shockwave ^ Codigos
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4126
  • Karma: 223
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: 2D Scroll and sine dots.
« Reply #1 on: February 28, 2007 »
Runs very smooth here. Excellent!
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 16781
  • Karma: 439
  • evil/good
    • View Profile
    • My Homepage
Re: 2D Scroll and sine dots.
« Reply #2 on: February 28, 2007 »
I'd forgotten about this one to be honest Benny, I was tidying up the old computer today and I remembered I'd done some experimenting with Purebasic.. It is a good language and I just thought I'd put up my (old and embarrasing) examples! I'd love it if there was more PB demos to be honest. PB could be a very good language to use provided the user is prepared to pay for the license. It's worth it though.
Shockwave ^ Codigos
Challenge Trophies Won: