Topic: Some new code . . .  (Read 7339 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 code . . .
« on: October 30, 2008, 09:44:39 PM »
This is something I am working on for christmas - it will eventually be a christmas message . . .

Comments please? Basically, does it look like snow?
« Last Edit: July 08, 2009, 08:56:08 AM by AndyRCM »
"I could see the faces of those who led pissing themselves laughing" - Funeral Pyre by The Jam

Offline Andy

  • Amiga 4000
  • ******
  • Posts: 2468
  • Kudos 17
  • Gender: Male
    • View Profile
    • Retro Computers
Re: Some new code . . .
« Reply #1 on: October 30, 2008, 11:21:00 PM »
Looks like snow to me.... (Did you get the idea from my up and coming website theme!  ;D )

gooner

  • Guest
Re: Some new code . . .
« Reply #2 on: November 13, 2008, 06:31:16 PM »
Certainly looks like snow to me mate.
How about putting some of your previous work on these forums especialy the Christmas ones as the festive season approaches they will go down perfect and i'm sure a lot of your members haven't had the pleasure of seeing them :)

http://dbfinteractive.com/forum/index.php?topic=2685.0#lastPost

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 code . . .
« Reply #3 on: November 13, 2008, 06:34:56 PM »
Thanks gooner! I forgot about those! I will post them on here!
Andy
"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 new code . . .
« Reply #4 on: November 13, 2008, 08:53:29 PM »
you doing in FREEBASIC?

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 code . . .
« Reply #5 on: November 13, 2008, 10:13:03 PM »
Yes mate - everything i do is either in freebasic.

Andy
"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 new code . . .
« Reply #6 on: November 13, 2008, 11:24:08 PM »
I have notice that #include "fbgfx.bi" library is easy to display Picture or Sprites on the screen than Freebasic with tinyptc!

I also found two Brilliant Freebasic Tutorial which are

http://lachie.phatcode.net/articles.php

http://games.freebasic.net/dumpbyid.php?input=69
« Last Edit: November 13, 2008, 11:58:33 PM by Amiga Man »

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 code . . .
« Reply #7 on: November 14, 2008, 08:32:45 AM »
I still prefer to use tinyptc . . . to be honest it really is superb . . . just takes a little work to get your head around it.
Thanks to Shockwave over on DBF who makes it easy for beginners to pick up his code and other people over there are always very friendly!
If you are a coder or want to code certainly go over and join their forums - :)

Andy
"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 new code . . .
« Reply #8 on: November 14, 2008, 03:23:11 PM »
I am not really big fan of Freebasic with tinyptc because you have mess about fuctions for drawimage and put music in as it all
too much hassle!!!  >:(

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 code . . .
« Reply #9 on: December 17, 2008, 10:48:24 PM »
Here you go again - the snow demo - here is the code (just in case you want to see how i have done it . . .)

Code: [Select]

' SNOWING? by Andy of RCM - 28/10/08
' Dedicated to my family and friends
' amended 17/12/08 to sort out dodgy code!

#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)
dim shared as integer r,g,b
Dim Shared as double x1(sf),y1(sf)
dim shared as integer r1,g1,b1
Dim Shared as double x2(sf),y2(sf)
dim shared as integer r2,g2,b2
Dim shared as integer a,bb(xres)
Dim shared as double q,w,m
Dim shared as String key

Declare Sub DrawSnow
Declare Sub MoveSnow
Declare Sub DrawFlakes1
Declare Sub DrawFlakes2
Declare Sub DrawFlakes3

for a=0 to sf-1
    x(a)=2+(int(rnd(1)*xres)-1)
    y(a)=2+(int(rnd(1)*yres)-1)
    x1(a)=2+(int(rnd(1)*xres)-1)
    y1(a)=2+(int(rnd(1)*yres)-1)
    x2(a)=2+(int(rnd(1)*xres)-1)
    y2(a)=2+(int(rnd(1)*yres)-1)
next
   
    r=120:g=120:b=255
    r1=170:g1=170:b1=255
    r2=255:g2=255:b2=255
   
    ptc_allowclose(0)
    ptc_setdialog(1,"Would you like to go Fullscreen?",0,1)
   
If( ptc_open( "Parallax Snowfield - 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$()
    DrawSnow
    MoveSnow
    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 DrawSnow
    for a=0 to sf-1
        DrawFlakes1
        DrawFlakes2
        DrawFlakes3
    next a
End Sub

Sub MoveSnow
    for a=0 to sf-1
        y(a)=y(a)+2
        y1(a)=y1(a)+3
        y2(a)=y2(a)+4
        q=int(rnd(1)*6)
        w=int(rnd(1)*6)
        m=int(rnd(1)*6)
        if q>3 then x(a)=x(a)+.4
        if w>3 then x1(a)=x1(a)+.6
        if m>3 then x2(a)=x2(a)+.8
        if q<3 then x(a)=x(a)-.4
        if w<3 then x1(a)=x1(a)-.6
        if m<3 then x2(a)=x2(a)-.8
        if x(a)<=0 then x(a)=xres-1
        if x(a)>=xres then x(a)=1
        if x1(a)<=0 then x1(a)=xres-1
        if x1(a)>=xres then x1(a)=1
        if x2(a)<=0 then x2(a)=xres-1
        if x2(a)>=xres then x2(a)=xres-1
        if y(a)>=yres-1 then y(a)=1
        if y1(a)>=yres-1 then y1(a)=1
        if y2(a)>=yres-1 then y2(a)=1
    next a
End Sub

Sub DrawFlakes1()
    pp(x(a),y(a),rgb(r,g,b))
    pp(x(a)-1,y(a),rgb(r,g,b))
    pp(x(a)+1,y(a),rgb(r,g,b))
    pp(x(a)+xres,y(a),rgb(r,g,b))
    pp(x(a)-xres,y(a),rgb(r,g,b))
End Sub

Sub DrawFlakes2()
    pp(x1(a),y1(a),rgb(r1,g1,b1))
    pp(x1(a)-1,y1(a),rgb(r1,g1,b1))
    pp(x1(a)+1,y1(a),rgb(r1,g1,b1))
    pp(x1(a)+xres,y1(a),rgb(r1,g1,b1))
    pp(x1(a)-xres,y1(a),rgb(r1,g1,b1))
End Sub

Sub DrawFlakes3()
    pp(x2(a),y2(a),rgb(r2,g2,b2))
    pp(x2(a)-1,y2(a),rgb(r2,g2,b2))
    pp(x2(a)+1,y2(a),rgb(r2,g2,b2))
    pp(x2(a)+xres,y2(a),rgb(r2,g2,b2))
    pp(x2(a)-xres,y2(a),rgb(r2,g2,b2))
End Sub

and also attached an .exe for the snow too . . . runs in both full screen and windowed mode now!
"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 new code . . .
« Reply #10 on: January 02, 2009, 05:31:51 PM »
What I really love about that is that you've delta timed it.

Props to you Andy. Well done.

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 code . . .
« Reply #11 on: January 04, 2009, 01:20:02 PM »
Thanks Shockwave! It is all thanks to you and the guys on DBF!

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