gfxgfxFreeBASIC Games Directory Forumgfxgfx
gfx gfx
gfx
Welcome, Guest. Please login or register. May 20, 2013, 04:39:45 PM

Login with username, password and session length
11.5.2013 - Added a webpage for the latest FBGD competition.

13.3.2013 - Members registrations temporary disabled. For all membership requests, please email me: lachie13@yahoo.com

30.11.2012 - The ninth issue of BASIC Gaming is out! Read it here: http://games.freebasic.net/forum/index.php?topic=560.0

22.11.2012 - Be sure to check our currently running annual FBGD game making competition. This year's theme is SEASONS OF THE YEAR, 300 $ first place prize, and the competition runs till 18th of February. Link: http://games.freebasic.net/forum/index.php?topic=559.0
gfx
gfx
*
gfxgfx
gfxgfx gfxgfx
gfxgfx Home Help Search Login Register   gfxgfx
gfx gfx
gfx
Pages: [1] 2 3
Print
Author Topic: Blast The Roids [ Now Here! ]  (Read 2963 times)
rolliebollocks
Novice
***
Posts: 75


View Profile Email
« on: September 11, 2010, 12:45:53 PM »

Ok, so this is the stupidest thing ever, but it isn't exactly done.

Download:

www.imakegames.com/~rolliebollocks/_RB_LIB_roids_beta.zip

Screenie:



Lemme know what you guys think of the mouse controls... I tried a different spin on an old game, and this is really only three hours worth of setting up a working engine, so you won't hurt my feelings no matter what you say.

« Last Edit: September 11, 2010, 01:23:23 PM by rolliebollocks » Logged
Brick Break
Forum Sage
*****
Gender: Male
Posts: 412



View Profile
« Reply #1 on: September 11, 2010, 01:08:30 PM »

The page was deleted. Or at least the download was. The screenshot looks nice though.
Logged

Lachie Dazdarian
Double dipper
Administrator
Forum Sage
*****
Gender: Male
Posts: 1195


lachie13
View Profile WWW Email
« Reply #2 on: September 12, 2010, 03:45:40 AM »

The download works.

Anyway, I like the story. Very....rolliebollocks.

Nice concept for controls. The gameplay needs more tuning, that's for sure. The first impression is that I have way too much energy and it would take me ages to die. Also, I shouldn't be allowed to fire another projectile until the old one hits something or exits the screen, my opinon. Or I should be allowed to shoot more than one projectile.

The sounds are...crazy, but I don't mind crazy.

Keep tuning this. Make the game more dynamic, faster, and maybe add enemies that follow and shoot at you later.

Also, what's up with the highscore values? INT that!
Logged

"Things like Basic and Free Basic provide much-needed therapy and a return to sanity and a correct appreciation of people. The arrogant folk really hate a word like 'Basic' - fine, and good riddance." ~ pragmatist
rolliebollocks
Novice
***
Posts: 75


View Profile Email
« Reply #3 on: September 12, 2010, 08:33:03 AM »

@Lachie

Thanks! I always wanted to do a space rpg. Do you remember Solar Winds? I think I'm going to go that route. But before I get there, I'm going to do a clone of Demon Attack and Centipede and some other old Atari deals. And of course finish this up.

I'll do multiple projectiles, or map pickups for special cannons or something.

BTW: Your name is too long, and now I have to resize my button for PolyDraw.
Logged
Lachie Dazdarian
Double dipper
Administrator
Forum Sage
*****
Gender: Male
Posts: 1195


lachie13
View Profile WWW Email
« Reply #4 on: September 12, 2010, 10:14:05 AM »

I have similar ambitons too, because I loved Solar Winds Episode I when I originally played it, and wondered why this game is not a classic...until I played Episode 2 that completely shat on all the potential from Episode I.

What PolyDraw button?
Logged

"Things like Basic and Free Basic provide much-needed therapy and a return to sanity and a correct appreciation of people. The arrogant folk really hate a word like 'Basic' - fine, and good riddance." ~ pragmatist
Brick Break
Forum Sage
*****
Gender: Male
Posts: 412



View Profile
« Reply #5 on: September 12, 2010, 10:30:26 AM »

Quote
The download works.
It didn't before.
Quote
Anyway, I like the story. Very....rolliebollocks.
I guess I wasn't here for his other stuff.

Quote
Nice concept for controls. The gameplay needs more tuning, that's for sure. The first impression is that I have way too much energy and it would take me ages to die. Also, I shouldn't be allowed to fire another projectile until the old one hits something or exits the screen, my opinon. Or I should be allowed to shoot more than one projectile.

The sounds are...crazy, but I don't mind crazy.

Keep tuning this. Make the game more dynamic, faster, and maybe add enemies that follow and shoot at you later.
Can't wait to play it! Too bad there's not a binary. I'll compile it and give it a spin, don't worry. There's a lot of stuff in there- including possibly the triangle drawing function I need. Cheesy
Quote
Also, what's up with the highscore values? INT that!
facepalm
Quote
Thanks! I always wanted to do a space rpg. Do you remember Solar Winds? I think I'm going to go that route. But before I get there, I'm going to do a clone of Demon Attack and Centipede and some other old Atari deals. And of course finish this up.
Those old Atari games can be implemented in JavaScript with my efficient tablecanvas drawing library. It would be nice to play stuff on the web without downloading everything.
Quote
I'll do multiple projectiles, or map pickups for special cannons or something.
Nice!
Quote
BTW: Your name is too long, and now I have to resize my button for PolyDraw.
I don't quite get that...
Quote
have similar ambitons too, because I loved Solar Winds Episode I when I originally played it, and wondered why this game is not a classic...until I played Episode 2 that completely shat on all the potential from Episode I.
Never played Solar Winds.
Quote
What PolyDraw button?
Exactly. That looks like a PolyDraw ship in the screenshot, though.
Logged

rolliebollocks
Novice
***
Posts: 75


View Profile Email
« Reply #6 on: September 12, 2010, 11:39:12 AM »

@BrickBreak

Yeah I screwed up the link. And then my stupid internet explorer crashed everytime I tried to access this thread. So I downloaded google chrome...

If you go into my Sandbox, click Apps on the mainmenu, I included PolyDraw, and JaDogg's Special Effects producer, because they're both great progs for game development and were distributed freely saying it was ok to redistribute, as I figure most everything is... If you're going to post a project, and someone thinks it's really great and wants to include it with there stuff that should count as a success right?

I gave credit to you both in the buttons... PolyDraw ( by Lachie Dazdarian... ) but your name extends beyond the length of the button... So now I have to elongate my button to accomodate your name.

Logged
Brick Break
Forum Sage
*****
Gender: Male
Posts: 412



View Profile
« Reply #7 on: September 12, 2010, 12:15:02 PM »

Quote
Yeah I screwed up the link. And then my stupid internet explorer crashed everytime I tried to access this thread. So I downloaded google chrome...
That's a good browser if you don't mind being watched.
Quote
If you go into my Sandbox, click Apps on the mainmenu, I included PolyDraw, and JaDogg's Special Effects producer, because they're both great progs for game development and were distributed freely saying it was ok to redistribute, as I figure most everything is... If you're going to post a project, and someone thinks it's really great and wants to include it with there stuff that should count as a success right?
Hey, it would be great if I made something people could use in their projects.
Logged

rolliebollocks
Novice
***
Posts: 75


View Profile Email
« Reply #8 on: September 12, 2010, 12:39:50 PM »

This is the only triangle drawing function you will ever need:

I believe it's written by Dr D.

'Stolen from the Extended Library.

sub TriangleASM( byval dst as FB.IMAGE ptr = 0, byval x1 as integer, byval y1 as integer, byval x2 as integer, byval y2 as integer, byval x3 as integer, byval y3 as integer, byval col as uinteger = rgba(255,255,255,255) )
       
        dim as any ptr dstptr
        dim as integer dw, dh, dp
       
        if dst = 0 then
            dstptr = screenptr
            screeninfo dw,dh
            dp = dw * 4
        else
            dstptr = cast( any ptr, dst + 1 )
            dw = dst->width
            dh = dst->height
            dp = dst->pitch
        end if
       
        if y2 < y1 then
            swap y1, y2
            swap x1, x2
        end if
       
        if y3 < y1 then
            swap y3, y1
            swap x3, x1
        end if
       
        if y3 < y2 then
            swap y3, y2
            swap x3, x2
        end if
       
        dim as single d1, d2, d3
       
        scope
            dim as integer dx1, dy1
            dx1 = x2 - x1
            dy1 = y2 - y1
            if dy1 <> 0 then
                d1 = dx1 / dy1
            else
                d1 = 0
            end if
        end scope
       
        scope
            dim as integer dx2, dy2
            dx2 = x3 - x2
            dy2 = y3 - y2
            if dy2 <> 0 then
                d2 = dx2 / dy2
            else
                d2 = 0
            end if
        end scope
       
        scope
            dim as integer dx3, dy3
            dx3 = x1 - x3
            dy3 = y1 - y3
            if dy3 <> 0 then
                d3 = dx3 / dy3
            else
                d3 = 0
            end if
        end scope
       
        dim as single lx, rx
       
        lx = x1
        rx = x1
       
        dim as single  lx_incr = any
        dim as single  rx_incr = any
        dim as integer y_start  = any
        dim as integer y_end    = any
       
        for t as integer = 0 to 1
            if t = 0 then
                lx_incr = d1
                rx_incr = d3
                y_start = y1
                y_end   = y2 - 1
            else
                lx_incr = d2
                rx_incr = d3
                y_start = y2
                y_end   = y3
                lx      = x2
            end if
           
            dim as any ptr __dstptr = dstptr + (y_start * dp)
           
            if y_end >= dh then y_end = dh - 1
           
            dim as integer y_draw_count = (y_end - y_start) + 1
            if y_draw_count > 0 then
                dim as integer y = any
               
                asm
                    mov edx, dword ptr [y_draw_count]
                   
                    mov eax, dword ptr [y_start]
                    mov dword ptr [y], eax
                   
                    fld dword ptr [lx_incr]
                    fld dword ptr [rx_incr]
                    fld dword ptr [lx]
                    fld dword ptr [rx]
                   
                    y_inner:
                   
                    cmp dword ptr [y], -1
                    jle no_x_draw
                    sub esp, 4
                   
                    fld st(1)
                    fistp dword ptr [esp]
                    mov esi, dword ptr [esp]
                   
                    fist dword ptr [esp]
                    mov edi, dword ptr [esp]
                   
                    add esp, 4
                    cmp esi, edi
                    jle no_swap
                   
                    mov eax, esi
                    mov esi, edi
                    mov edi, eax
                   
                    no_swap:
                   
                    cmp esi, 0
                    jge no_clip_start_x
                   
                    mov esi, 0
                   
                    no_clip_start_x:
                   
                    mov eax, dword ptr [dw]
                    cmp edi, eax
                    jl no_clip_end_x
                   
                    dec eax
                    mov edi, eax
                   
                    no_clip_end_x:
                   
                    mov ebx, esi
                    shl ebx, 2
                    add ebx, dword ptr [__dstptr]
                    mov ecx, edi
                    sub ecx, esi
                    mov eax, dword ptr [col]
                    inc ecx
                    jle no_x_draw
                   
                    x_inner:
                   
                    mov dword ptr [ebx], eax
                    add ebx, 4
                    dec ecx
                    jnz x_inner
                   
                    no_x_draw:
                   
                    fld st(3)
                    faddp st(2), st(0)
                   
                    fadd st(2)
                   
                    mov eax, dword ptr [dp]
                    add dword ptr [__dstptr], eax
                   
                    inc dword ptr [y]
                   
                    y_test:
                    dec edx
                    jnz y_inner
                   
                    fstp dword ptr [rx]
                    fstp dword ptr [lx]
                   
                    finit
                   
                end asm
            end if
        next t
       
    end sub
   
Logged
Brick Break
Forum Sage
*****
Gender: Male
Posts: 412



View Profile
« Reply #9 on: September 12, 2010, 12:59:23 PM »

We had this problem before. It has ASM. That won't work.
Logged

rolliebollocks
Novice
***
Posts: 75


View Profile Email
« Reply #10 on: September 12, 2010, 01:18:36 PM »

Here's a DJ Peter's version... I have more if you like...

#define scr_w  640
#define scr_h  480
#define scr_b    8 ' 8,15,16,24 or 32

#define SHIFTS   8 ' 24:8 fixed point format

#if (scr_b=8)
  Type pixel As Ubyte
  #undef RGB
  #define RGB(r,g,b) ((r And &HE0) Or ((g And &HE0) Shr 3) Or ((b And &HC0) Shr 6))
  Sub Palette332()
    Dim As Integer i,r,g,b
    For i = 0 To 255
      r=(((i Shr 5) And &H07) * 255) / 7
      g=(((i Shr 2) And &H07) * 255) / 7
      b=(((i Shr 0) And &H03) * 255) / 3
      Palette i,r,g,b
    Next
  End Sub
#elseif (scr_b=15) Or (scr_b=16)
  Type pixel As Ushort
  #undef RGB
  #define RGB(r,g,b) (((r Shr 3) Shl 11) Or ((g Shr 2) Shl 5) Or (b Shr 3))
#elseif (scr_b=24) Or (scr_b=32)
  Type pixel As Uinteger
#else
  #error bits per pixel (scr_b) must be 8,15,16,24 Or 32
#endif

Type screen2d
  As Integer x,y
End Type

Sub Polygone(d   As pixel Ptr, _ ' screen ptr
             p() As screen2d , _ ' the coords (x,y)
             n   As Integer  , _ ' how many coords in array
             c   As pixel    , _ ' fillcolor
             b   As pixel  =0, _ ' optional bordercolor
             u   As Integer=0)   ' optional use bordercolor
  #define mr 1000000
  Dim As Integer   f  =Any,ty =Any,by=Any,l  =Any,r=Any
  Dim As Integer   lc =Any,nlc=Any,rc=Any,nrc=Any
  Dim As Integer   d1 =Any,s1 =Any,d2=Any,s2 =Any,cl=Any,cr=Any
  Dim As pixel Ptr row=Any,cstart=Any,cend=Any
  n-=1:If n<2 Then Exit Sub
  ty=mr:by=-mr:l=mr:r=-mr
  For nc As Integer=0 To n
    With p(nc)
      If .y<ty Then ty=.y:f=nc
      If .y>by Then by=.y
      If .x<l  Then l=.x
      If .x>r  Then r=.x
    End With
  Next
  ' clip
  If l>=scr_w     Then Exit Sub
  If r<1          Then Exit Sub
  If ty>=scr_h    Then Exit Sub
  If by<0         Then Exit Sub
  If (r-l)<1      Then Exit Sub
  If by>=scr_h    Then by=scr_h-1
  If (by-ty)<1    Then Exit Sub

  lc=f:nlc=lc-1:If nlc<0 Then nlc=n
  rc=f:nrc=rc+1:If nrc>n Then nrc=0
  If p(nlc).x>p(nrc).x Then Exit Sub
 
  row=d+ty*scr_w
  While ty<by
    If ty=p(lc).y Then
      While p(lc).y=p(nlc).y
        lc=nlc:nlc-=1:If nlc<0 Then nlc=n
      Wend
      d1=p(lc).x Shl SHIFTS
      s1=((p(nlc).x-p(lc).x) Shl SHIFTS)/(p(nlc).y-p(lc).y)
      lc = nlc
    End If
    If ty=p(rc).y Then
      While p(rc).y=p(nrc).y
        rc=nrc:nrc+=1:If nrc>n Then nrc=0
      Wend
      d2=p(rc).x Shl SHIFTS
      s2=((p(nrc).x-p(rc).x) Shl SHIFTS)/(p(nrc).y-p(rc).y)
      rc=nrc
    End If

    If ty<0     Then Goto next_filled_scanline
    l=d1 Shr SHIFTS:r=d2 Shr SHIFTS
    If l>r      Then Swap l,r
    If l>=scr_w Then Goto next_filled_scanline
    If r<0      Then Goto next_filled_scanline
    cl=0:cr=0 ' reset clipflag
    If l<0      Then l=0      :cl=1
    If r>=scr_w Then r=scr_w-1:cr=1
   
    cstart=row+l ' first pixel
    cend  =row+r ' last pixel
    ' use border
    If u Then
      If cl=0 Then *cstart=b:cstart+=1
      If cr=0 Then *cend  =b
    End If
    While cstart<cend:*cstart=c:cstart+=1:Wend
    next_filled_scanline:
    ty+=1:d1+=s1:d2+=s2:row+=scr_w
  Wend
End Sub

Sub triangle(d   As pixel Ptr, _
             p() As screen2d , _
             c   As pixel    , _ ' fillcolor
             b   As pixel=0  , _ ' optional bordercolor
             u   As Integer=0)   ' optional use bordercolor
  Dim As Integer   yt =Any,yb=Any,l=Any,r=Any
  Dim As Integer   d1 =Any,d2=Any,s1=Any,s2=Any,cl=Any,cr=Any
  Dim As pixel Ptr row=Any,cstart=Any,cend=Any
  Dim As screen2d  v0 =Any,v1=Any,v2=Any
  v0=p(0):v1=p(1):v2=p(2)
  If (v1.y>v2.y) Then Swap v1,v2
  If (v0.y>v2.y) Then Swap v0,v2
  If (v0.y>v1.y) Then Swap v0,v1
  If (v2.y=v0.y) Then Return
  s1=((v2.x-v0.x) Shl SHIFTS)/(v2.y-v0.y)
  d1=v0.x Shl SHIFTS
  For i As Integer=0 To 1
    s2=((v1.x-v0.x) Shl SHIFTS)/(v1.y-v0.y)
    d2=v0.x Shl SHIFTS
    yt=v0.y
    ' begin in first row
    If yt<0 Then
      d1-=s1*yt
      d2-=s2*yt
      yt=0
    End If
    yb=v1.y
    ' end in last row
    If yb>=scr_h Then yb=scr_h-1
    If yb<=yt    Then Goto next_triangle
    row=d+yt*scr_w ' first row
    yb-=yt ' how many scanlines
    ' from top to bottom
    While yb
      l=d1 Shr SHIFTS:r=d2 Shr SHIFTS
      If l>r      Then Swap l,r
      If l>=scr_w Then Goto next_scanline
      If r<1      Then Goto next_scanline
      cl=0:cr=0   ' reset clipflag
      If l<0      Then l=0    :cl=1
      If r>=scr_w Then r=scr_w:cr=1
      cstart=row+l ' first pixel
      cend  =row+r ' last  pixel
      If u Then ' use border
        If cl=0 Then *cstart=b:cstart+=1
        If cr=0 Then *cend  =b
      End If
      While cstart<cend:*cstart=c:cstart+=1:Wend
      next_scanline:
      d1+=s1:d2+=s2:row+=scr_w:yb-=1
    Wend
    next_triangle:
    d1= (v0.x Shl SHIFTS)+((v1.y-v0.y)*s1)
    v0=v1:v1=v2
  Next
End Sub
 
'
' main
'
Dim As screen2d t(2),p(9)
Dim As pixel   fc,bc ' colors
Dim As Integer fps,frames,mx,my
Dim As Single  w1,w2
Dim As Double  t1,t2

screenres scr_w,scr_h,scr_b,,1
#if scr_b=8
  Palette332
#endif

t1=Timer
While Inkey=""
  If getmouse(mx,my)=0 Then
    screenlock:Cls
    For i As Integer=0 To 2
      With t(i)
        .x=mx+Cos(w1+i*2)*100-100
        .y=my+Sin(w1+i*2)*100
      End With
    Next
    For i As Integer=0 To 9
      With p(i)
        .x=mx+Cos(w2+i*0.628)*100+100
        .y=my+Sin(w2+i*0.628)*100
      End With
    Next
    w1+=0.001:w2-=0.002
    frames+=1

    'polygone screenptr,p(),10,rgb(255,0,0)
    'triangle screenptr,t()   ,rgb(0,0,255)
    polygone screenptr,p(),10,rgb(255,0,0) ,rgb(0  ,255,0),1
    triangle screenptr,t()   ,rgb(0,0,255) ,rgb(255,255,0),1

    Print "fps=" & fps & "   "
    screenunlock
    If frames=100 Then
      t2 =Timer
      fps=frames/(t2-t1)
      t1 =t2:frames=0
      'sleep 1
    End If
  End If
Wend
End
Logged
Brick Break
Forum Sage
*****
Gender: Male
Posts: 412



View Profile
« Reply #11 on: September 12, 2010, 03:52:21 PM »

More would be good. Do you have anything in the style of the FB extended library, but with *var=value; style addressing instead of ASM?
Logged

rolliebollocks
Novice
***
Posts: 75


View Profile Email
« Reply #12 on: September 12, 2010, 04:36:56 PM »

Yes, but it uses EXT dependent features to extract the pixel data which means you have to use the library...

Uhm... This is Rel's I bet...

Type Vect2D
        x As Double
        y As Double
End Type

Type Vect3D
        x As Double
        y As Double
        z As Double
End Type

Type Poly2D
        p1 As Vect2D
        p2 As Vect2D
        p3 As Vect2D
End Type

Type Poly3D
        p1 As Vect3D
        p2 As Vect3D
        p3 As Vect3D
End Type

Declare Sub InsidePoly(p As Poly2D, v As Vect2D, Byref inside As Integer = 0)
Declare Sub InsidePoly3D(p As Poly3D, v As Vect3D, Byref inside As Integer = 0)
Dim ink As String
Screen 19

Dim poly As Poly2D
Dim vect As Vect2D
Dim in As Integer

poly.p1.x = 50
poly.p1.y = 25
poly.p2.x = 30
poly.p2.y = 27
poly.p3.x = 70
poly.p3.y = 123

vect.x = 25
vect.y = 50

Do While ink<>Chr(27)
        Cls
        ink = Inkey
        If ink = "w" Then
                vect.y -= 1
        Endif
        If ink = "s" Then
                vect.y += 1
        Endif
        If ink = "a" Then
                vect.x -= 1
        Endif
        If ink = "d" Then
                vect.x += 1
        Endif
        Line(poly.p1.x, poly.p1.y)-(poly.p2.x, poly.p2.y), 3
        Line(poly.p2.x, poly.p2.y)-(poly.p3.x, poly.p3.y), 3
        Line(poly.p3.x, poly.p3.y)-(poly.p1.x, poly.p1.y), 3
        Pset(vect.x, vect.y), 5
        InsidePoly(poly, vect, in)
        Pset(vect.x, vect.y), 5
        Print in       
Loop



Sub InsidePoly(p As Poly2D, v As Vect2D, Byref inside As Integer = 0)
        Dim x1 As Double = p.p1.x
        Dim y1 As Double = p.p1.y
        Dim x2 As Double = p.p2.x
        Dim y2 As Double = p.p2.y
        Dim x3 As Double = p.p3.x
        Dim y3 As Double = p.p3.y
        Dim y As Double
        Dim lx As Double
        Dim rx As Double
        Dim dx1 As Double
        Dim dx2 As Double
        Dim dx3 As Double
        Dim dy1 As Double
        Dim dy2 As Double
        Dim dy3 As Double
       
        If y2 < y1 Then
                Swap y2, y1
                Swap x2, x1
        Endif
       
        If y3 < y2 Then
                Swap y3, y2
                Swap x3, x2
        Endif
       
        If y3 < y1 Then
                Swap y3, y1
                Swap x3, x1
        Endif
       
        dx1 = x2 - x1
        dx2 = x3 - x2
        dx3 = x3 - x1
        dy1 = y2 - y1
        dy2 = y3 - y2
        dy3 = y3 - y1
       
        rx = x1
        lx = x1
        For y = y1 To y2 - 1
               
                If (v.y > y - 1) Or (v.y < y + 1) Then
                        If rx > lx Then
                                If v.x < rx Then
                                        If v.x > lx Then
                                                inside = 1
                                                Exit Sub
                                        Endif
                                Endif
                        Endif
                       
                        If lx > rx Then
                                If v.x > rx Then
                                        If v.x < lx Then
                                                inside = 1
                                                Exit Sub
                                        Endif
                                Endif
                        Endif
                Endif
                Line(rx, y)-(lx, y),3
                rx = rx + (dx3 / dy3)
                lx = lx + (dx1 / dy1)
        Next
       
        For y = y2 To y3
               
                If (v.y > y - 1) Or (v.y < y + 1) Then
                        If rx > lx Then
                                If v.x < rx Then
                                        If v.x > lx Then
                                                inside = 1
                                                Exit Sub
                                        Endif
                                Endif
                        Endif
                       
                        If lx > rx Then
                                If v.x > rx Then
                                        If v.x < lx Then
                                                inside = 1
                                                Exit Sub
                                        Endif
                                Endif
                        Endif
                Endif
                Line(rx, y)-(lx, y), 3
                rx = rx + (dx3 / dy3)
                lx = lx + (dx2 / dy2)
        Next
       
End Sub

Sub InsidePoly3D(p As Poly3D, v As Vect3D, Byref inside As Integer = 0)
        Dim x1 As Double = p.p1.x
        Dim y1 As Double = p.p1.y
        Dim z1 As Double = p.p1.z
        Dim x2 As Double = p.p2.x
        Dim y2 As Double = p.p2.y
        Dim z2 As Double = p.p2.z
        Dim x3 As Double = p.p3.x
        Dim y3 As Double = p.p3.y
        Dim z3 As Double = p.p3.z
        Dim z As Double
        Dim lx As Double
        Dim rx As Double
        Dim dx1 As Double
        Dim dx2 As Double
        Dim dx3 As Double
        Dim dy1 As Double
        Dim dy2 As Double
        Dim dy3 As Double
        Dim dz1 As Double
        Dim dz2 As Double
        Dim dz3 As Double
       
        If z2 < z1 Then
                Swap y2, y1
                Swap x2, x1
                Swap z2, z1
        Endif
       
        If z3 < z2 Then
                Swap y3, y2
                Swap x3, x2
                Swap z3, z2
        Endif
       
        If z3 < z1 Then
                Swap y3, y1
                Swap x3, x1
                Swap z3, z1
        Endif
       
        dx1 = x2 - x1
        dx2 = x3 - x2
        dx3 = x3 - x1
        dy1 = y2 - y1
        dy2 = y3 - y2
        dy3 = y3 - y1
        dz1 = z2 - z1
        dz2 = z3 - z2
        dz3 = z3 - z1
       
        rx = x1
        lx = x1
        For z = z1 To z2 - 1
               
                If (v.z > z - 1) Or (v.z < z + 1) Then
                        If rx > lx Then
                                If v.x < rx Then
                                        If v.x > lx Then
                                                inside = 1
                                                Exit Sub
                                        Endif
                                Endif
                        Endif
                       
                        If lx > rx Then
                                If v.x > rx Then
                                        If v.x < lx Then
                                                inside = 1
                                                Exit Sub
                                        Endif
                                Endif
                        Endif
                Endif
                If dz3 <> 0 Then
                        rx = rx + (dx3 / dz3)
                End If
                If dz1 <> 0 Then
                        lx = lx + (dx1 / dz1)
                End If
        Next
       
        For z = z2 To z3
               
                If (v.z > z - 1) Or (v.z < z + 1) Then
                        If rx > lx Then
                                If v.x < rx Then
                                        If v.x > lx Then
                                                inside = 1
                                                Exit Sub
                                        Endif
                                Endif
                        Endif
                       
                        If lx > rx Then
                                If v.x > rx Then
                                        If v.x < lx Then
                                                inside = 1
                                                Exit Sub
                                        Endif
                                Endif
                        Endif
                Endif
               
                If dz3 <> 0 Then
                        rx = rx + (dx3 / dz3)
                End If
                If dz2 <> 0 Then
                        lx = lx + (dx2 / dz2)
                End If
        Next
       
End Sub


 
Logged
Brick Break
Forum Sage
*****
Gender: Male
Posts: 412



View Profile
« Reply #13 on: September 13, 2010, 01:18:33 PM »

Yes, but it uses EXT dependent features to extract the pixel data which means you have to use the library...

Extracting the pixel data is only used for transparency and stuff. Are you telling me there isn't an efficient, self-contained triangle drawing function? It should be less than 50 lines, MIT, BSD or Public Domain licensed, and not use any extensions.
Logged

rolliebollocks
Novice
***
Posts: 75


View Profile Email
« Reply #14 on: September 15, 2010, 07:29:54 AM »

No, the pixel data is extracted from the ScreenPtr to make the draws faster by circumventing PSET.

It has to be able to fill the polygon, right? All these functions are for *filling* the triangles with a solid color.

You can avoid doing that completely by cookie cutting a triangle out of a fb.image buffer which is way faster (and the method that I use for most things).

Rel's version is very similiar to the EXT version, and does not use any dependent vars. What's wrong with that?

The algo is based on the slope formula.
Logged
Pages: [1] 2 3
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
Cerberus design by Bloc
Valid XHTML 1.0! Valid CSS!
gfx
gfxgfx gfxgfx