2D-Starscroller + Line Drawing

Share your advanced PureBasic knowledge/code with the community.
chosc
New User
New User
Posts: 4
Joined: Mon May 26, 2003 1:38 am

2D-Starscroller + Line Drawing

Post by chosc »

Updated for version 5.20

Hello , after i learned a little bit from other coders here in the Forum
i programmed this example here :

A nice Starscroller from left to right with some line Drawings in it !

Have Fun !
:D

Code: Select all

#desw=400 
#desh=150
anzahl.l = 200

array:
Structure Star
 x.f 
 y.f 
 v.f 
 col.f
EndStructure

Dim stern.Star(anzahl)
For array = 0 To anzahl
 Stern(array)\x = Random(#desw)
 Stern(array)\y = Random(#desh)
 Stern(array)\v = 0.5 + Random(45)/30
 Stern(array)\col = 100 + Random(900)
Next array

Procedure Drawchar(zeichen.s,x.f,y.f,col.b,gr.b)
 Select zeichen
 Case "c"
 Line (x,y,gr,0,col)
 Line (x,y,0,gr,col)
 Line (x,y+gr,gr,0)
 Case "h"
 Line (x,y,0,gr+1,col)
 Line (x,y+gr/2,gr,0,col)
 Line (x+gr,y,0,gr+1,col)
 Case "o"
 Line (x,y,gr,0,col)
 Line (x,y,0,gr,col)
 Line (x,y+gr,gr,0)
 Line (x+gr,y,0,gr+1,col)
 Case "s"
 Line (x,y,gr,0,col)
 Line (x,y,0,gr/2,col)
 Line (x,y+gr/2,gr,0,col)
 Line (x,y+gr,gr,0,col)
 Line (x+gr,y+gr/2,0,gr/2+1,col)
 EndSelect 
EndProcedure

;Gosub array
InitSprite()
OpenWindow(0,150,150,#desw,#desh,#PB_Window_SystemMenu | #PB_Window_MinimizeGadget,"=-window-=") ; Open the window game
OpenWindowedScreen(WindowID(),0,0,#desw,#desh,0,1,1)
posx.l=1
a.l=1
b.l=1
g.b=18
posy.b=#desh/2-10
Repeat
ClearScreen(0,0,0)
StartDrawing(ScreenOutput())
Drawchar("c",20+posx,posy,255,g)
Drawchar("h",40+posx,posy,255,g)
Drawchar("o",60+posx,posy,255,g)
Drawchar("s",80+posx,posy,255,g)
Drawchar("c",100+posx,posy,255,g)
posx=posx+a
posy=posy+b
If posx = #desw-120
a=-1
EndIf
If posx = 1 
a=1
EndIf
If posy = #desh-40
b=-1
EndIf
If posy = 10 
b=1
EndIf

For many = 0 To anzahl
If Stern(many)\x > #desw
   Stern(many)\x = Random(#desw)
   Stern(many)\y = Random(#desh)
   Stern(many)\v = 0.5 + Random(45)/10   
   Stern(many)\col = 100 + Random(900)
Else
Stern(many)\x = Stern(many)\x + Stern(many)\v
x=Stern(many)\x
y=Stern(many)\y
col = 255-(Stern(many)\col *(255./1000.)) 
Plot (x,y,RGB ( col,col,col ) )
EndIf
Next many

StopDrawing() 
FlipBuffers()
EventID.l = WindowEvent()
Until EventID = #PB_EventCloseWindow
Cor
Enthusiast
Enthusiast
Posts: 124
Joined: Fri Apr 25, 2003 7:52 pm
Location: Netherlands
Contact:

Post by Cor »

Great,

works here W98 SE
Cor de Visser

Registered PureBasic user

Author of ChordPlanet
Made with PureBasic
http://www.chordplanet.com
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Purebasic - Linker error
sprite_nt.lib : unknown file type

while compiling under NT4sp5
TronDoc
Enthusiast
Enthusiast
Posts: 310
Joined: Wed Apr 30, 2003 3:50 am
Location: 3DoorsDown

Post by TronDoc »

nifty!
works here: w98fe
--Joe
peace
[pI 166Mhz 32Mb w95]
[pII 350Mhz 256Mb atir3RagePro WinDoze '98 FE & 2k]
[Athlon 1.3Ghz 160Mb XPHome & RedHat9]
Post Reply