Author Topic: Another starfield that differs to Clydes!  (Read 2433 times)

0 Members and 1 Guest are viewing this topic.

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Another starfield that differs to Clydes!
« on: December 16, 2006 »
Here you go - as already posted within Clydes thread . . . thought I would re-post under my own!!

Feedback welcome!

Drew

Code: [Select]
option explicit
#include once "tinyptc.bi"

const xres = 1024
const yres = 768
Dim shared as Integer NS
NS=64
Dim shared as Integer x(ns),y(ns)
Dim Shared as Integer x1(ns),y1(ns)
Dim Shared as Integer x2(ns),y2(ns)
Dim Shared as Integer x3(ns),y3(ns)
Dim shared as Integer a
Dim shared as String key
Declare Sub DrawStars1
Declare Sub MoveStars1

for a=0 to ns-1
  Â  x(a)=int(rnd(1)*xres)
  Â  y(a)=int(rnd(1)*yres)
  Â  x1(a)=int(rnd(1)*xres)
  Â  y1(a)=int(rnd(1)*yres)
  Â  x2(a)=int(rnd(1)*xres)
  Â  y2(a)=int(rnd(1)*yres)
  Â  x3(a)=int(rnd(1)*xres)
  Â  y3(a)=int(rnd(1)*yres)
next

If( ptc_open( "Starfield", XRES, YRES ) = 0 ) Then
End -1
End If
Dim Shared sb(xres*yres)
#define PP(x,y,argb) sb(y*XRES+x)=argb

while key<>chr$(27)
  Â  key = inkey$()
  Â  erase sb(0)
  Â  DrawStars1
  Â  MoveStars1
  Â  ptc_update @sb(0)
Wend

Sub DrawStars1
  Â  for a=0 to ns-1
  Â  Â  Â  pp(x(a),y(a),rgb(255,255,255))
  Â  Â  Â  pp(x1(a),y1(a),rgb(192,192,192))
  Â  Â  Â  pp(x2(a),y2(a),rgb(128,128,128))
  Â  Â  Â  pp(x3(a),y3(a),rgb(64,64,64))
  Â  next a
End Sub

Sub MoveStars1
  Â  for a=0 to ns-1
  Â  Â  Â  x(a)=x(a)+8
  Â  Â  Â  x1(a)=x1(a)+4
  Â  Â  Â  x2(a)=x2(a)+2
  Â  Â  Â  x3(a)=x3(a)+1
  Â  Â  Â  if x(a)>=xres then x(a)=0
  Â  Â  Â  if x1(a)>=xres then x1(a)=0
  Â  Â  Â  if x2(a)>=xres then x2(a)=0
  Â  Â  Â  if x3(a)>=xres then x3(a)=0
  Â  next a
End Sub
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: Another starfield that differs to Clydes!
« Reply #1 on: December 16, 2006 »
btw - change the NS figure to the number of stars required - go on . . . put a higher figure in there!!! It's still relatively smooth!!!!
and if you want more layers . . . just add x4,y4 etc etc into the code . . . it works, i have had eight parallax layers scrolling!!!

Drew
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Another starfield that differs to Clydes!
« Reply #2 on: December 16, 2006 »
Nice one DrewPee :)
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won: