Page 1 of 1

2D-Starscroller + Line Drawing

Posted: Thu Jun 05, 2003 8:22 pm
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

Posted: Thu Jun 05, 2003 9:33 pm
by Cor
Great,

works here W98 SE

Posted: Sat Jun 07, 2003 11:11 am
by gnozal
Purebasic - Linker error
sprite_nt.lib : unknown file type

while compiling under NT4sp5

Posted: Sat Jun 07, 2003 10:48 pm
by TronDoc
nifty!
works here: w98fe
--Joe