Topic: Some new (old) code . . .  (Read 8838 times)

Author Message

0 Members and 1 Guest are viewing this topic.

Offline AndyRCM

  • >=))))º> GO FEED THE FISH! <º((((=<
  • Administrator
  • Amiga 4000
  • ******
  • Posts: 9675
  • Kudos 50
  • Gender: Male
  • Manic Jet Set Willy
    • View Profile
    • Retro Computer Museum
Some new (old) code . . .
« on: April 07, 2009, 09:37:42 PM »
Hello again, sorry to bore you shitless with this . . .
After loosing most of my code . . . bloody hard disks!!!!!! I started again . . . with my starfield routine and came up with the attached.
Basically it now uses one field of stars instead of several to create a parallax scrolling effect . . .
If you want to see the code, please ask! I don't mind posting it if people want to see it!

Andy
« Last Edit: July 08, 2009, 08:55:03 AM by AndyRCM »
"I could see the faces of those who led pissing themselves laughing" - Funeral Pyre by The Jam

Offline AndyRCM

  • >=))))º> GO FEED THE FISH! <º((((=<
  • Administrator
  • Amiga 4000
  • ******
  • Posts: 9675
  • Kudos 50
  • Gender: Male
  • Manic Jet Set Willy
    • View Profile
    • Retro Computer Museum
Re: Some new (old) code . . .
« Reply #1 on: April 07, 2009, 09:49:22 PM »
Meant to say - the zip file contains a .exe, so if you don't mind running executables please do run it . . . if not . . . I will post a screen shot if you want me to . . . wont look like much tho! ;)
"I could see the faces of those who led pissing themselves laughing" - Funeral Pyre by The Jam

Offline AndyRCM

  • >=))))º> GO FEED THE FISH! <º((((=<
  • Administrator
  • Amiga 4000
  • ******
  • Posts: 9675
  • Kudos 50
  • Gender: Male
  • Manic Jet Set Willy
    • View Profile
    • Retro Computer Museum
Re: Some new (old) code . . .
« Reply #2 on: April 07, 2009, 09:58:19 PM »
I have decided to post the code anyway . . . here you go . . .

Code: [Select]
' Starfield v3 by Andy of RCM - 07/04/09
' Dedicated to my family and friends

#include once "tinyptc_ext.bi"
#include once "crt.bi"
#include once "windows.bi"

const xres = 800
const yres = 600

Dim shared as integer sf
sf=512
Dim shared as double x(sf),y(sf),s(sf)
dim shared as double r,g,b
Dim shared as integer a
Dim shared as String key
Dim shared as integer bib
Dim shared as integer q

Declare Sub DLine(ypos,r as double,g as double,b as double,wid)
Declare Sub Stars

for a=0 to sf-1
    x(a)=(int(rnd(1)*xres)-1)
    y(a)=1+(int(rnd(1)*yres)-1)
    s(a)=1+(int(rnd(1)*8)) 
next

    r=255:g=255:b=255
    ptc_allowclose(0)
    ptc_setdialog(1,"Would you like to go Fullscreen?",0,1)
    If( ptc_open( "Starfield - Again!", XRES, YRES ) = 0 ) Then
    End -1
    End If

Dim Shared as Integer sb(xres*yres)
#define pp(x,y,argb) sb(y*XRES+x)=argb
Dim Shared As LARGE_INTEGER Frequency
Dim Shared As LARGE_INTEGER LiStart
Dim Shared As LARGE_INTEGER LiStop
Dim Shared As LONGLONG LlTimeDiff
Dim Shared As Double MDuration

QueryPerformanceFrequency( @Frequency )

WHILE(GETASYNCKEYSTATE(VK_ESCAPE)<> -32767 and PTC_GETLEFTBUTTON=FALSE)
    QueryPerformanceCounter( @LiStart )
    key = inkey$()
    Stars
    DLine(0,255,128,16,24)
    DLine(yres-25,255,128,16,24)
    DLine(24,255,255,255,2)
    DLine(yres-25,255,255,255,2)
    ptc_update @sb(0)
    erase sb
        do
        QueryPerformanceCounter( @LiStop )
        LlTimeDiff = LiStop.QuadPart - LiStart.QuadPart
        MDuration = Cast( Double, LlTimeDiff ) * 1000.0 / Cast( Double , Frequency.QuadPart )
        Loop While (  MDuration <= 1000.0/60.0 )'60fps Clamp change the 60.0 to whatever fps you need
Wend

ptc_close()
end

Sub Stars
    for a=0 to sf-1
        x(a)=x(a)-s(a)
        bib=int(rnd(1)*8)
        if bib=3 and y(a)>1 then y(a)=y(a)-1:r=int(rnd(1)*255):g=r:b=g
        if bib=6 and y(a)<yres-1 then y(a)=y(a)+1:r=int(rnd(1)*255):g=r:b=g
        if y(a)<1 then y(a)=yres-1
        if y(a)>yres-1 then y(a)=1
        if x(a)<0 then x(a)=(xres-1):y(a)=1+(int(rnd(1)*yres)-1)
        if y(a)<0 then x(a)=1
        if y(a)>yres then x(a)=yres-1       
        pp(x(a),y(a),rgb(r,g,b))
    next a
End Sub

Sub DLine(ypos,r as double,g as double,b as double,wid)
    for a=0 to xres-1
        for q=ypos to ypos+wid
        pp(a,q,rgb(r,g,b))
        next q
        if r>32 then r=r-.2
        if g>8 then g=g-.2
        if b>4 then b=b-.2 
    next a
End Sub

Hopefully somebody might find it useful?

It is written in freebasic!
"I could see the faces of those who led pissing themselves laughing" - Funeral Pyre by The Jam

Offline billdooruk

  • Administrator
  • Amiga 4000
  • ******
  • Posts: 2476
  • Kudos 26
  • Gender: Male
  • I could murder a curry
    • View Profile
    • Our site:-
Re: Some new (old) code . . .
« Reply #3 on: April 07, 2009, 10:23:56 PM »
Is this the one you showed us at Byte Back?

I liked it then  :D

Offline AndyRCM

  • >=))))º> GO FEED THE FISH! <º((((=<
  • Administrator
  • Amiga 4000
  • ******
  • Posts: 9675
  • Kudos 50
  • Gender: Male
  • Manic Jet Set Willy
    • View Profile
    • Retro Computer Museum
Re: Some new (old) code . . .
« Reply #4 on: April 07, 2009, 10:25:24 PM »
Sort of . . . been tweaked a lot since then! Nearly completely new code!

Andy
"I could see the faces of those who led pissing themselves laughing" - Funeral Pyre by The Jam

Offline billdooruk

  • Administrator
  • Amiga 4000
  • ******
  • Posts: 2476
  • Kudos 26
  • Gender: Male
  • I could murder a curry
    • View Profile
    • Our site:-
Re: Some new (old) code . . .
« Reply #5 on: April 07, 2009, 10:28:31 PM »
Cool.....

Just like looking out of a side window on the NCC1701-D (I am that sad!!!!)  ;D

Offline AndyRCM

  • >=))))º> GO FEED THE FISH! <º((((=<
  • Administrator
  • Amiga 4000
  • ******
  • Posts: 9675
  • Kudos 50
  • Gender: Male
  • Manic Jet Set Willy
    • View Profile
    • Retro Computer Museum
Re: Some new (old) code . . .
« Reply #6 on: April 07, 2009, 10:30:59 PM »
Thanks Karl - that is praise indeed! ;)

The code I used before used several 'lots' of stars in different layers, this new code uses one layer but different 'speeds' of each star - it can be any speed from 1 pixel to 8 pixels per move . . . ;)
"I could see the faces of those who led pissing themselves laughing" - Funeral Pyre by The Jam

Offline Scarlettkitten

  • Enjoy the silence
  • Administrator
  • Amiga 4000
  • ******
  • Posts: 2025
  • Kudos 31
  • Queen of the 3DO people
    • View Profile
Re: Some new (old) code . . .
« Reply #7 on: April 07, 2009, 10:36:50 PM »
It's made of stars :D

I like it, next can you make it rotate a'la Phenomena Enigma demo on the Amiga, that would be uber cool 8)

Offline AndyRCM

  • >=))))º> GO FEED THE FISH! <º((((=<
  • Administrator
  • Amiga 4000
  • ******
  • Posts: 9675
  • Kudos 50
  • Gender: Male
  • Manic Jet Set Willy
    • View Profile
    • Retro Computer Museum
Re: Some new (old) code . . .
« Reply #8 on: April 07, 2009, 10:38:36 PM »
I think so yes! Leave that one with me! ;)

Andy
"I could see the faces of those who led pissing themselves laughing" - Funeral Pyre by The Jam

Offline Scarlettkitten

  • Enjoy the silence
  • Administrator
  • Amiga 4000
  • ******
  • Posts: 2025
  • Kudos 31
  • Queen of the 3DO people
    • View Profile
Re: Some new (old) code . . .
« Reply #9 on: April 07, 2009, 10:42:47 PM »
I'm catchin you up with the code writing :D, I've started reading "The Easy programming guide for the Atari micros" (8-bit) even this book seems over my head, but I'm determined to give it a go.


Offline AndyRCM

  • >=))))º> GO FEED THE FISH! <º((((=<
  • Administrator
  • Amiga 4000
  • ******
  • Posts: 9675
  • Kudos 50
  • Gender: Male
  • Manic Jet Set Willy
    • View Profile
    • Retro Computer Museum
Re: Some new (old) code . . .
« Reply #10 on: April 07, 2009, 10:44:11 PM »
Meant to say, I love the Phenomena Enigma demo on the Amiga - superb stuff!

But I love Desert Dreams more!!! Now If I could code something like that - dribble, drool etc . . .
"I could see the faces of those who led pissing themselves laughing" - Funeral Pyre by The Jam

Offline Scarlettkitten

  • Enjoy the silence
  • Administrator
  • Amiga 4000
  • ******
  • Posts: 2025
  • Kudos 31
  • Queen of the 3DO people
    • View Profile
Re: Some new (old) code . . .
« Reply #11 on: April 07, 2009, 10:45:10 PM »
Phenomena Enigma is my favorite, the raytraced fractal animation is superb. 8)

Offline AndyRCM

  • >=))))º> GO FEED THE FISH! <º((((=<
  • Administrator
  • Amiga 4000
  • ******
  • Posts: 9675
  • Kudos 50
  • Gender: Male
  • Manic Jet Set Willy
    • View Profile
    • Retro Computer Museum
Re: Some new (old) code . . .
« Reply #12 on: April 15, 2009, 09:22:41 PM »
I have now done a 3d starfield . . .

.exe and screenshot attached! although screenshot is a black screen with white dots . . . :(
"I could see the faces of those who led pissing themselves laughing" - Funeral Pyre by The Jam

Offline Scarlettkitten

  • Enjoy the silence
  • Administrator
  • Amiga 4000
  • ******
  • Posts: 2025
  • Kudos 31
  • Queen of the 3DO people
    • View Profile
Re: Some new (old) code . . .
« Reply #13 on: April 15, 2009, 09:31:36 PM »
Looking good 8)

Offline AndyRCM

  • >=))))º> GO FEED THE FISH! <º((((=<
  • Administrator
  • Amiga 4000
  • ******
  • Posts: 9675
  • Kudos 50
  • Gender: Male
  • Manic Jet Set Willy
    • View Profile
    • Retro Computer Museum
Re: Some new (old) code . . .
« Reply #14 on: April 15, 2009, 09:33:09 PM »
Thanks mate - just working on spinning it now! ;)
"I could see the faces of those who led pissing themselves laughing" - Funeral Pyre by The Jam