Topic: Some more crappy code . . .  (Read 11200 times)

Author Message

0 Members and 1 Guest are viewing this topic.

Offline Panther

  • Committee
  • Amiga 4000
  • *
  • Posts: 4180
  • Kudos 35
  • Gender: Male
  • Look at the size of my.......Paws
    • View Profile
Re: Some more crappy code . . .
« Reply #15 on: July 03, 2009, 09:58:31 AM »
Pretty neat Andy  :)

Will try the Freebasic when I get time  :-\ whenever that may be !

Offline Amiga Man

  • Amiga 4000
  • ******
  • Posts: 999
  • Kudos 10
    • View Profile
Re: Some more crappy code . . .
« Reply #16 on: July 04, 2009, 11:49:57 AM »
Hey AndyRCM,

You could Do Tutorial for Freebasic  :P :)

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 more crappy code . . .
« Reply #17 on: July 04, 2009, 12:25:52 PM »
Yeah I think I might do that sometime - just to help people start . . . ;)
"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 more crappy code . . .
« Reply #18 on: July 04, 2009, 06:23:54 PM »
Something else I have knocked together . . .

a laser type effect . . . something I have tried to do in the past but failed miserably - this came to me in a flash . . .

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

Offline Shockwave

  • RCM Programmer.
  • user
  • C128
  • *
  • Posts: 307
  • Kudos 14
  • Gender: Male
    • View Profile
    • My Home Page
Re: Some more crappy code . . .
« Reply #19 on: July 05, 2009, 09:46:41 PM »
I like the laser idea :)

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 more crappy code . . .
« Reply #20 on: July 05, 2009, 09:48:59 PM »
Thanks Shockwave! I have been trying to do this effect for so long . . . a little more tweaking and I think I will be happy with it!
I will post it on DBF when I am happier with it - okay?
"I could see the faces of those who led pissing themselves laughing" - Funeral Pyre by The Jam

Offline Panther

  • Committee
  • Amiga 4000
  • *
  • Posts: 4180
  • Kudos 35
  • Gender: Male
  • Look at the size of my.......Paws
    • View Profile
Re: Some more crappy code . . .
« Reply #21 on: July 05, 2009, 11:22:29 PM »
Downloaded Freebasic, just need to get some time to play !!!

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 more crappy code . . .
« Reply #22 on: July 06, 2009, 03:47:51 PM »
@Panther - did you want me to post some code . . . as a framework? Did you download tinyptc_ext as well from the dbf website? If not, i recommend that you do!
"I could see the faces of those who led pissing themselves laughing" - Funeral Pyre by The Jam

Offline Amiga Man

  • Amiga 4000
  • ******
  • Posts: 999
  • Kudos 10
    • View Profile
Re: Some more crappy code . . .
« Reply #23 on: July 06, 2009, 03:59:44 PM »

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 more crappy code . . .
« Reply #24 on: July 06, 2009, 07:28:12 PM »
@AmigaMan - trouble is with that - it uses built in graphics commands - which in my opinion are not that good.

I would recommend that anybody going into freebasic should use tinyptc_ext - much more control ;)

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

Offline Panther

  • Committee
  • Amiga 4000
  • *
  • Posts: 4180
  • Kudos 35
  • Gender: Male
  • Look at the size of my.......Paws
    • View Profile
Re: Some more crappy code . . .
« Reply #25 on: July 06, 2009, 08:23:11 PM »
Well I've started on the first few tentative steps into freebasic, and just shows how long it's been since I programmed anything in basic, pretty much lost to start with  :-[

Think I need some lessons !!!

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 more crappy code . . .
« Reply #26 on: July 06, 2009, 08:37:05 PM »
Panther - follow the topics mentioned above by AmigaMan - and in the meantime I will post code here too! ;)

in fact . . .

Code: [Select]

#include once "tinyptc_ext.bi" ' this is the extension that you need

const xres = 800 'screen x width
const yres = 600 'screeen y height

Dim shared as integer s 'stars
s=512 ' number of stars
Dim shared as double x(s),y(s) ' x and y co-ordinates for each star
Dim shared as integer a,o,p ' three variables just for small routines

Declare Sub Stars ' you have to declare each subroutine you use
Declare Sub ClearScreen ' so we are using two subroutines

for a=0 to s-1 ' set up star co-ordinates
    x(a)=(int(rnd(1)*xres)-1)
    y(a)=1+(int(rnd(1)*yres)-1)
next

    ptc_allowclose(0) ' these lines create either a window or full screen
    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) ' this basically sets up a buffer for the screen
#define pp(x,y,argb) sb(y*XRES+x)=argb ' this sets up a 'put pixel' command

WHILE(GETASYNCKEYSTATE(VK_ESCAPE)<> -32767 and PTC_GETLEFTBUTTON=FALSE) ' will loop untilo either left mouse button or escape are pressed
    Stars ' call routine stars
    ptc_update @sb(0) ' update the screen buffer
    ClearScreen ' as it says - just clear the screen
Wend

ptc_close() ' when routine finishes just close the screens you have used
end

Sub Stars ' this is for drawing and moving the starfield
    for a=0 to s-1
        x(a)=x(a)-4
        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(255,255,255)) ' red=255 green=255 blue=255 ' white!
    next a
End Sub

Sub ClearScreen ' this clears the screen with black
    for o=0 to xres-1
        for p=0 to yres-1
            pp(o,p,rgb(0,0,0)) ' red=0 green=0 blue=0
        next
    next
End Sub

you can copy and paste the above code straight into FBIDE . . . okay?
"I could see the faces of those who led pissing themselves laughing" - Funeral Pyre by The Jam

Offline Panther

  • Committee
  • Amiga 4000
  • *
  • Posts: 4180
  • Kudos 35
  • Gender: Male
  • Look at the size of my.......Paws
    • View Profile
Re: Some more crappy code . . .
« Reply #27 on: July 07, 2009, 08:02:27 AM »
Cheers Andy,

Thanks for all the comment notes, very helpful  :)

I gather from a quick read through of the code that the 'ptc' command is a reference to the screen in use and that 'pp' is like a pixel plot command with x co-ordinate, y co-ordinate then the colour, and finally that you can't have a variable 'a' in a For & Next loop without first using 'Dim a' ?

Oh and one last thing, is -

Dim shared as integer a,o,p       just a quicker way, rather than doing

Dim a as integer
Dim o as integer
Dim p as integer

???

Sorry for the questions mate  :o

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 more crappy code . . .
« Reply #28 on: July 07, 2009, 08:19:40 AM »
All correct! ;) Nice one!

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

Offline Panther

  • Committee
  • Amiga 4000
  • *
  • Posts: 4180
  • Kudos 35
  • Gender: Male
  • Look at the size of my.......Paws
    • View Profile
Re: Some more crappy code . . .
« Reply #29 on: July 07, 2009, 09:27:52 AM »
Just noticed through closer inspection of the code, that 'pp' isn't a command on it's own, but rather one you defined.

I can see this is going to take me some time to get my head around  :-\ The old grey matter ain't as sharp as it used to be  :-[ some would say it was never that sharp to start with  :P