Author Topic: Laser (sort of) effect . . . help please?  (Read 5735 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
Laser (sort of) effect . . . help please?
« on: December 06, 2007 »
Hello
Been working on this for a couple of hours . . .

Code: [Select]
#include once "tinyptc_ext.bi"
#include once "crt.bi"

        Const xres=600
        Const yres=480
       
        Declare Sub lin(Byval X1 as Integer, Byval Y1 as Integer, Byval X2 as Integer, Byval Y2 as Integer, Byval LR as Integer, Byval LG as Integer, Byval LB as Integer)       

        Dim Shared as UInteger Buffer(XRES*YRES)
        Dim shared as String key
        Dim Shared as Integer a,b,c,d,b1,e,f,lop,rr,gg,bb,rn
       
        #define PP(x,y,argb) buffer(y*XRES+x)=argb
       
        c=299:d=479:a=199:b=199:b1=1
        rr=255:gg=0:bb=0
       
        ptc_setdialog(1,"Do You Want Full Screen? ",0,0)
        if ( ptc_open ( "Laser Test by Drew", xres, yres) = 0 ) then
        end -1
        end if
           
        while key<>chr$(27)
            key = inkey$()
            lin(c,d,b,a,255,255,255)
            for lop=0 to 63
            rn=int(rnd(1)*10)
            e=(int(rnd(1)*-14))+(int(rnd(1)*14))
            f=1+(int(rnd(1)*-14))+(int(rnd(1)*14))
            if rn<5 then rr=255:gg=0:bb=0
            if rn>5 then rr=255:gg=255:bb=0
            pp(b+e,(a+(f)),rgb(rr,gg,bb))
            next lop
            ptc_update@Buffer(0)
            erase buffer
            b=b+b1
            if b>=499 then a=a+4
            if b>=499 then b1=-1
            if b<99 then a=a+4
            if b<99 then b1=1
            if a>299 then a=199           
        Wend

'LINE Drawing Routine by Shockwave (Thanks Dude!)
SUB LIN(BYVAL X1 AS INTEGER , BYVAL Y1 AS INTEGER , BYVAL X2 AS INTEGER , BYVAL Y2 AS INTEGER , BYVAL LR AS INTEGER, BYVAL LG AS INTEGER, BYVAL LB AS INTEGER)
        DIM xdistance AS DOUBLE
        DIM ydistance AS DOUBLE
        DIM TC AS INTEGER       
        DIM i AS INTEGER
        DIM h2 AS INTEGER       
        DIM StartX AS DOUBLE
        DIM StartY AS DOUBLE
        DIM XRatio AS DOUBLE
        DIM YRatio AS DOUBLE
        TC = RGB ( LR,LG,LB )
        xdistance = X2 - X1
        ydistance = Y2 - Y1
        h2 = sqr( xdistance * xdistance + ydistance * ydistance )
        StartX = X1
        StartY = Y1
        XRatio = xdistance * ( 1.0 / h2 )
        YRatio = ydistance * ( 1.0 / h2 )
        for i = 0 to h2
            IF STARTX>0 AND STARTX<XRES AND STARTY>0 AND STARTY<YRES THEN
            BUFFER ( INT(StartX) + (INT(StartY) * XRES ) ) = TC
            END IF
            StartX = StartX + XRatio
            StartY = StartY + YRatio
        next i
END SUB

when i go to fullscreen it just quits out . . . anybody any ideas?
windowed mode works fine!

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

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Laser (sort of) effect . . . help please?
« Reply #1 on: December 06, 2007 »
600x480 isn't a standard fullscreen resolution.  Try 640x480.
Jim
Challenge Trophies Won:

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: Laser (sort of) effect . . . help please?
« Reply #2 on: December 07, 2007 »
doh! of course, never noticed that . . . sad! thanks Jim!!!

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

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Laser (sort of) effect . . . help please?
« Reply #3 on: December 07, 2007 »
Cool lazer :)

Lets see it drawing some stuff!
Shockwave ^ Codigos
Challenge Trophies Won:

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: Laser (sort of) effect . . . help please?
« Reply #4 on: December 09, 2007 »
Shockwave,
Yeah that is the idea, does anybody remember the electronic arts logo on the amiga, a laser went around the edge of a box then the peice fell out to reveal their logo! wow! loved that idea as well! I think it was on Turrican?!?!?!? Im not sure tho?
Im hoping to etch a logo or text as the laser hits the screen or something like that - not sure if i can do it yet tho? I will try and show you guys the results!!

Cheers

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

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: Laser (sort of) effect . . . help please?
« Reply #5 on: December 09, 2007 »
Yeah, I remember that on Turrican.

I came up with a laser effect with lines in opengl by making them slightly transparent, if you're going to be drawing it in front of anything on the screen that might be an idea.

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: Laser (sort of) effect . . . help please?
« Reply #6 on: December 09, 2007 »
This actually sounds like a nice idea for competition : laser intro
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Laser (sort of) effect . . . help please?
« Reply #7 on: December 09, 2007 »
Yep. It would be a good one.
Shockwave ^ Codigos
Challenge Trophies Won:

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: Laser (sort of) effect . . . help please?
« Reply #8 on: December 09, 2007 »
Guys, do you mean to say Ive come up with a good idea . . . sod me!!! that don't happen very often!!!!! lol!

I have no idea how to make mine transparent and I also have no idea about OpenGL . . . thats me fekked then!

Cheers guys

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

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: Laser (sort of) effect . . . help please?
« Reply #9 on: December 09, 2007 »
Don't worry too much about the opengl side of things in this case but to make it transparent use some sort of blending, additive might be best for this where you simply add the colour value of the laser light to the pixel colour value and clamp it to the max value (must be done for each colour component r,g,b) but you might have to alter the line drawing function so there's no overdraw of pixels, that would be done by making either Xratio or Yratio (whichever has the largest magnitude) equal to + or - 1 and calculating the other to suit that size of step.

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: Laser (sort of) effect . . . help please?
« Reply #10 on: December 10, 2007 »
Stonemonkey . . . can that be done using tinyptc then? I understand what you mean as I use photoshop and use the blending modes on that. Not sure if I would be able to implement what you are talking about as I am using Shockwaves line drawing routine anyway (which I now understand!).

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

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: Laser (sort of) effect . . . help please?
« Reply #11 on: December 10, 2007 »
Yep, can be done with tinyptc, you have to read the colour value first from the pixel you're about to write to then separate the rgb values, add or blend the colour values you want to write with those (clamping if using additive blending) then combining the rgb values back together and writing to the pixel.

I've posted some alpha blending code somewhere before but you might have to alter the line drawing code or you might be able to get away with using a low blending value with the overdraw giving a cumulative effect.

EDIT:

this uses the alpha part (bits 24-31) of the source colour for blending
http://dbfinteractive.com/index.php?topic=307.msg3840#msg3840
« Last Edit: December 10, 2007 by Stonemonkey »

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: Laser (sort of) effect . . . help please?
« Reply #12 on: December 10, 2007 »
Thanks stonemonkey - I will have a go at this now . . . cheers dude!

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