Author Topic: Line/circle collision  (Read 373 times)

Marcus

  • Administrator
  • Hero Member
  • *****
  • Posts: 542
    • View Profile
Line/circle collision
« on: May 05, 2017 »
Experimented some with collision handling between a user controlled circle and some static and rotating lines. Was just making a test of how to handle some things in a 3D game. Usually I handle collisions WHILE moving an object, but here I do tests AFTER moving by "pushing" the circle away if there's an intersection.


Code: [Select]
import "Keycodes.lib"
import "Math.lib"

lines#[4][4]
lines[1][0] = 100.0
lines[1][1] = 100.0
lines[1][2] = 500.0
lines[1][3] = 300.0
lines[2][0] = 100.0
lines[2][1] = 100.0
lines[2][2] = 132.0
lines[2][3] = 400.0


circleX# = 100.0
circleY# = 200.0
circleR# = 32.0

set redraw off

lineA# = 0.0
do
dx# = 0.0
dy# = 0.0
if keydown(VK_LEFT) then dx# = dx# - 4.0
if keydown(VK_RIGHT) then dx# = dx# + 4.0
if keydown(VK_UP) then dy# = dy# - 4.0
if keydown(VK_DOWN) then dy# = dy# + 4.0
circleX = circleX + dx
circleY = circleY + dy

lineA = lineA + 1.0
lines[0][0] = 360.0 - cos(lineA)*160.0
lines[0][1] = 240.0 - sin(lineA)*160.0
lines[0][2] = 360.0 + cos(lineA)*160.0
lines[0][3] = 240.0 + sin(lineA)*160.0

lines[3][0] = 400.0 - cos(lineA*0.5)*100.0
lines[3][1] = 300.0 - sin(lineA*0.5)*100.0
lines[3][2] = 400.0 + cos(lineA*0.5)*100.0
lines[3][3] = 300.0 + sin(lineA*0.5)*100.0


' draw.
set color 0, 0, 0
cls

set color 255, 255, 255
for i = 0 to sizeof(lines, 0) - 1
draw line int(lines[i][0]), int(lines[i][1]), int(lines[i][2]), int(lines[i][3])
dx# = lines[i][2] - lines[i][0]
dy# = lines[i][3] - lines[i][1]
next

steps = 0
do
collision = false
for i = 0 to sizeof(lines, 0) - 1
if CLInt(circleX, circleY, circleR, lines[i][0], lines[i][1], lines[i][2], lines[i][3])
collision = true
endif
next
steps = steps + 1
until collision = false or steps = 4

set color 255, 255, 0
draw pixel int(circleX), int(circleY)
for i = 0 to 12
a1# = float(i)*360.0/12.0
a2# = float(i + 1)*360.0/12.0
x1 = int(circleX + cos(a1)*circleR)
y1 = int(circleY + sin(a1)*circleR)
x2 = int(circleX + cos(a2)*circleR)
y2 = int(circleY + sin(a2)*circleR)
draw line x1, y1, x2, y2
next

redraw
wait 16
until keydown(27, true)

function CLInt(&cx#, &cy#, cr#, lx1#, ly1#, lx2#, ly2#)
c#[] = [cx - lx1, cy - ly1]
l#[] = [lx2 - lx1, ly2 - ly1]
lineLen# = V_Size(l)
param#
' p is the clost point ON the line to c.
p#[] = V_ProjectGet2(c, l, param)

' is the projection on the line?
if param >= 0.0 and param <= lineLen
dv#[] = V_SubGet(c, p)
if V_Size(dv) < cr
' dv is actually the normal of the line in the correct direction.
' so we can get the corrected position.
_V_Normalize dv
cx = lx1 + p[0] + dv[0]*cr
cy = ly1 + p[1] + dv[1]*cr
return true
else
return false
endif
' check closest distance to vertices.
else
' closest to first vertex?
if param < 0.0
ed# = DistanceF(cx, cy, lx1, ly1)
if ed < cr
' push out.
dv#[] = [cx - lx1, cy - ly1]
_V_Normalize dv
cx# = lx1 + dv[0]*cr
cy# = ly1 + dv[1]*cr
return true
else
return false
endif
' cosest to second vertex.
else
ed# = DistanceF(cx, cy, lx2, ly2)
if ed < cr
dv#[] = [cx - lx2, cy - ly2]
_V_Normalize dv
cx# = lx2 + dv[0]*cr
cy# = ly2 + dv[1]*cr
return true
else
return false
endif
endif
return false
endif

endfunc

function V_ProjectGet2#[](&u#[], &v#[], &p#)
n#[] = V_NormalizeGet(v)
s# = V_Dot(u, n)
p = s
return [n[0]*s, n[1]*s]
endfunc
« Last Edit: May 05, 2017 by Marcus »
.\\\opz

Rick3137

  • Sr. Member
  • ****
  • Posts: 342
  • May the Force be with You
    • View Profile
    • Rick's Programs
Re: Line/circle collision
« Reply #1 on: May 05, 2017 »
   Wow!

 It might take me awhile to figure out what you just did, but it works good.

Marcus

  • Administrator
  • Hero Member
  • *****
  • Posts: 542
    • View Profile
Re: Line/circle collision
« Reply #2 on: May 05, 2017 »
It might take me awhile to figure out what you just did, but it works good.

Not too complicated :)  I calculate the minimum distance between a circle's center and a line, and if the distance is less than the radius of the circle I move the circle out to the desired distance. It doesn't care where the circle or the line "came" from (movement or rotation) but only looks at the current positions. I'm actually surprised it works :D
« Last Edit: May 07, 2017 by Marcus »
.\\\opz

Marcus

  • Administrator
  • Hero Member
  • *****
  • Posts: 542
    • View Profile
Re: Line/circle collision
« Reply #3 on: May 09, 2017 »
Just another example of the same thing but using the polystuff library for fancier transformations and a polygon from the polyeditor.

Code: [Select]
import "Keycodes.lib"
import "Math.lib"
import "PolyStuff.lib"

circleX# = 100.0
circleY# = 200.0
circleR# = 32.0

set redraw off

' polygon created with the polygon editor.
pf#[][] = [[-40.0, -180.0], [40.0, -180.0], [20.0, -20.0], [180.0, -40.0], [180.0, 40.0], [20.0, 20.0], [40.0, 180.0], [-40.0, 180.0], [-20.0, 20.0], [-180.0, 40.0], [-180.0, -40.0], [-20.0, -20.0], [-40.0, -180.0]]

' angles for rotation and scaling.
angle# = 0.0
scaleAngle# = 0.0

do
' control sircle.
dx# = 0.0
dy# = 0.0
if keydown(VK_LEFT) then dx# = dx# - 4.0
if keydown(VK_RIGHT) then dx# = dx# + 4.0
if keydown(VK_UP) then dy# = dy# - 4.0
if keydown(VK_DOWN) then dy# = dy# + 4.0
circleX = circleX + dx
circleY = circleY + dy

' update polygon angles.
angle = angle + 0.5
if angle >= 360.0 then angle = angle - 360.0
scaleAngle = scaleAngle + 1.5
if scaleAngle >= 360.0 then scaleAngle = scaleAngle - 360.0

' make a copy of the original polygon and transform it some.
pft#[][] = pf
_ClearTransformation
_Translate 320.0, 240.0
_Rotate angle
_Scale 1.0 + sin(scaleAngle*2.0)*0.25, 1.0 - sin(scaleAngle*1.0)*0.25
_TransformPolygon pft
_ClearTransformation

' perform collision tests.
' the goal is ofcourse to do keep calling CLInt until there are no collisions,
' but some more tweaks need to be made for that to work; sometimes after a
' "vertex push" a collision is still reported which would hang the loop. also
' it would be desirable to test the lines and let them push in some order,
' maybe based on the size of the intersections.
steps = 0
do
collision = false
for i = 0 to sizeof(pft, 0) - 2
if CLInt(circleX, circleY, circleR, pft[i][0], pft[i][1], pft[i + 1][0], pft[i + 1][1])
collision = true
endif
next
steps = steps + 1
until collision = false or steps = 4


' draw.
set color 0, 0, 0
cls

set color 255, 255, 255
_DrawPolygon pft, true

set color 255, 255, 0
draw pixel int(circleX), int(circleY)
for i = 0 to 12
a1# = float(i)*360.0/12.0
a2# = float(i + 1)*360.0/12.0
x1 = int(circleX + cos(a1)*circleR)
y1 = int(circleY + sin(a1)*circleR)
x2 = int(circleX + cos(a2)*circleR)
y2 = int(circleY + sin(a2)*circleR)
draw line x1, y1, x2, y2
next

redraw
wait 16
until keydown(27, true)

function CLInt(&cx#, &cy#, cr#, lx1#, ly1#, lx2#, ly2#)
c#[] = [cx - lx1, cy - ly1]
l#[] = [lx2 - lx1, ly2 - ly1]
lineLen# = V_Size(l)
param#
' p is the clost point ON the line to c.
p#[] = V_ProjectGet2(c, l, param)

' is the projection on the line?
if param >= 0.0 and param <= lineLen
dv#[] = V_SubGet(c, p)
if V_Size(dv) < cr
' dv is actually the normal of the line in the correct direction.
' so we can get the corrected position.
_V_Normalize dv
cx = lx1 + p[0] + dv[0]*cr
cy = ly1 + p[1] + dv[1]*cr
return true
else
return false
endif
' check closest distance to vertices.
else
' closest to first vertex?
if param < 0.0
ed# = DistanceF(cx, cy, lx1, ly1)
if ed < cr
' push out.
dv#[] = [cx - lx1, cy - ly1]
_V_Normalize dv
cx# = lx1 + dv[0]*cr
cy# = ly1 + dv[1]*cr
return true
else
return false
endif
' cosest to second vertex.
else
ed# = DistanceF(cx, cy, lx2, ly2)
if ed < cr
dv#[] = [cx - lx2, cy - ly2]
_V_Normalize dv
cx# = lx2 + dv[0]*cr
cy# = ly2 + dv[1]*cr
return true
else
return false
endif
endif
return false
endif

endfunc

function V_ProjectGet2#[](&u#[], &v#[], &p#)
n#[] = V_NormalizeGet(v)
s# = V_Dot(u, n)
p = s
return [n[0]*s, n[1]*s]
endfunc
.\\\opz

Rick3137

  • Sr. Member
  • ****
  • Posts: 342
  • May the Force be with You
    • View Profile
    • Rick's Programs
Re: Line/circle collision
« Reply #4 on: May 11, 2017 »
 Works good.
 There ought to be some way to use this stuff on a rpg maze type game.

Marcus

  • Administrator
  • Hero Member
  • *****
  • Posts: 542
    • View Profile
Re: Line/circle collision
« Reply #5 on: May 12, 2017 »
Works good.
 There ought to be some way to use this stuff on a rpg maze type game.

If you look at the attached program (sourcecode and image attached in a zip), I'm doing a raycasting experiment with moving walls defined by arbitrary lines and collision handling using the stuff above. Not using the Raycaster library. Move and turn with the arrow keys.

Edit  This would ofcourse get incredibly slow with a big maze. I'll see what happens if I combine this with regular raycasting but for storing information in every cel about which walls pass through it. That way you don't need to check every ray against all walls. A quadtree would be perfect here, but implementing one in naalaa would be pretty hard :)

Code: [Select]
import "Speed.lib"
import "Math.lib"
import "Keycodes.lib"

constant:
GLOOM_TEXMODE_MIRROR 1
GLOOM_TEXMODE_STRETCH 2
GLOOM_TEXMODE_REPEAT 4

visible:
rc_Width = 320
rc_Height = 240
rc_Unit#
rc_AngleOffset#[]
rc_AngleOffsetCos#[]
rc_Distance#[][]
rc_ZBuffer#[]
rc_FOV# = 50.0

rc_Walls#[16][7]
rc_WallInfo[16][4]
rc_WallCount = 0

hidden:

set window 64, 64, 320, 240, false, 2

load image 0, "wall.bmp"

_GLOOM_InitView 60.0, width(primary), height(primary)

_GLOOM_AddWall 0, 0.0, 0.0, 16.0, 0.0, 16.0, 0
_GLOOM_AddWall 0, 16.0, 0.0, 16.0, 16.0, 16.0, 0
_GLOOM_AddWall 0, 16.0, 16.0, 0.0, 16.0, 16.0, 0
_GLOOM_AddWall 0, 0.0, 16.0, 0.0, 0.0, 16.0, 0

starPoly#[8][2]
starPoly[0][0] = 0.0; starPoly[0][1] = -4.0
starPoly[1][0] = 1.0; starPoly[1][1] = -1.0
starPoly[2][0] = 4.0; starPoly[2][1] = 0.0
starPoly[3][0] = 1.0; starPoly[3][1] = 1.0
starPoly[4][0] = 0.0; starPoly[4][1] = 4.0
starPoly[5][0] = -1.0; starPoly[5][1] = 1.0
starPoly[6][0] = -4.0; starPoly[6][1] = 0.0
starPoly[7][0] = -1.0; starPoly[7][1] = -1.0

starWall[8]
for i = 0 to 7
j = (i + 1)%8
starWall[i] = GLOOM_AddIndexedWall(0, 8.0 + starPoly[i][0], 8.0 + starPoly[i][1], 8.0 + starPoly[j][0] , 8.0 + starPoly[j][1], 2.0, 0)
next

playerX# = 14.5
playerZ# = 14.5
playerA# = 230.0
starWallAngle# = 0.0
shouldDraw = true
set redraw off
do
' update rotating star shaped wall.
starWallAngle = starWallAngle + 0.1
for i = 0 to 7
j = (i + 1)%8
a#[] = [starPoly[i][0], starPoly[i][1]]
b#[] = [starPoly[j][0], starPoly[j][1]]
_V_Rotate a, starWallAngle
_V_Rotate b, starWallAngle
_GLOOM_PositionWall starWall[i], 8.0 + a[0], 8.0 + a[1], 8.0 + b[0] , 8.0 + b[1]
next

if keydown(VK_LEFT)
playerA = playerA - 2.0
endif
if keydown(VK_RIGHT)
playerA = playerA + 2.0
endif
if keydown(VK_UP)
playerX = playerX + cos(playerA)*0.05
playerZ = playerZ + sin(playerA)*0.05
endif
if keydown(VK_DOWN)
playerX = playerX - cos(playerA)*0.05
playerZ = playerZ - sin(playerA)*0.05
endif

' collision handling for player.
_GLOOM_PushOut playerX, playerZ, 0.3

' draw.
if shouldDraw
set color 0, 0, 0
cls
set color 255, 255, 255, 0
_GLOOM_Render playerX, playerZ, playerA
redraw
endif

shoulDraw = SPD_HoldFrameDraw(60)
until keydown(27, true)

' copied from Raycaster.txt.
procedure GLOOM_InitView(fov#, renderW, renderH)
rc_FOV = fov
rc_Width = renderW
rc_Height = renderH
w = rc_Width
h = rc_Height
hw = w/2
hh = h/2
rc_Unit = float(hw)/tan(fov*0.5)
rc_AngleOffset#[w]
rc_AngleOffsetCos#[w]
rc_ZBuffer#[w]
for x = 0 to hw - 1
rc_AngleOffset[hw + x] = atan(float(x)/rc_Unit)
rc_AngleOffset[hw - 1 - x] = -rc_AngleOffset[hw + x]
rc_AngleOffsetCos[hw + x] = cos(rc_AngleOffset[hw + x])
rc_AngleOffsetCos[hw - 1 - x] = cos(rc_AngleOffset[hw - 1 - x])
next
rc_Distance[w][hh]
for x = 0 to w - 1
dconv# = 1.0/cos(rc_AngleOffset[x])
for y = 0 to hh - 1
d# = rc_Unit/float(h - 2*y)
d = d*dconv
rc_Distance[x][y] = d
next
next
endproc

procedure GLOOM_AddWall(img, x1#, z1#, x2#, z2#, repeat#, id)
rc_Walls[rc_WallCount][0] = x1
rc_Walls[rc_WallCount][1] = z1
rc_Walls[rc_WallCount][2] = x2
rc_Walls[rc_WallCount][3] = z2
rc_Walls[rc_WallCount][4] = x2 - x1
rc_Walls[rc_WallCount][5] = z2 - z1
rc_Walls[rc_WallCount][6] = repeat
rc_WallInfo[rc_WallCount][0] = img
rc_WallInfo[rc_WallCount][1] = id
rc_WallCount = rc_WallCount + 1
if rc_WallCount >= sizeof(rc_Walls, 0) then _GLOOM__ExpandWalls 8
endproc

function GLOOM_AddIndexedWall(img, x1#, z1#, x2#, z2#, repeat#, id)
index = rc_WallCount
_GLOOM_AddWall img, x1, z1, x2, z2, repeat, id
return index
endfunc

procedure GLOOM_PositionWall(index, x1#, z1#, x2#, z2#)
rc_Walls[index][0] = x1
rc_Walls[index][1] = z1
rc_Walls[index][2] = x2
rc_Walls[index][3] = z2
rc_Walls[index][4] = x2 - x1
rc_Walls[index][5] = z2 - z1
endproc

procedure GLOOM__ExpandWalls(num)
tmpWalls#[][] = rc_Walls
tmpWallInfo[][] = rc_WallInfo
rc_Walls[sizeof(tmpWalls, 0) + num][7]
rc_WallInfo[sizeof(tmpWalls, 0) + num][4]
for i = 0 to sizeof(tmpWalls, 0) - 1
for j = 0 to 7
rc_Walls[i][j] = tmpWalls[i][j]
next
for j = 0 to 3
rc_WallInfo[i][j] = tmpWallInfo[i][j]
next
next
endproc

procedure GLOOM_Render(xPos#, zPos#, angle#)
for x = 0 to rc_Width - 1
a# = rc_AngleOffset[x] + angle
rayX# = cos(a)
rayZ# = sin(a)
colX#
colZ#
rayParam#
wallParam#
minWallParam#
hit = false
minDistance# = 100000.0
for i = 0 to rc_WallCount - 1
if GLOOM__LLInt(xPos, zPos, rayX, rayZ, rc_Walls[i][0], rc_Walls[i][1], rc_Walls[i][4], rc_Walls[i][5], rayParam, wallParam
dx# = rayX*rayParam
dz# = rayZ*rayParam
d# = dx*dx + dz*dz
if d < minDistance
hit = true
wallHit = i
minDistance = d
minWallParam = wallParam
endif
endif
next
if hit
' scale according to minDistance
d = sqr(minDistance)*rc_AngleOffsetCos[x]
h = int(0.5*rc_Unit/d)
u# = minWallParam*rc_Walls[wallHit][6]
u = u - float(int(u))
draw vraster 0, x, rc_Height/2 - h, rc_Height/2 + h, u, 0.0, u, 1.0
endif
next
endproc

function GLOOM__LLInt(Ux#, Uy#, ux#, uy#, Vx#, Vy#, vx#, vy#, &u#, &v#)
wx# = Ux - Vx
wy# = Uy - Vy
' D# = perp(ux, uy, vx, vy)
D# = ux*vy - uy*vx
if abs#(D) < 0.00001 then return false

' u = perp(vx, vy, wx, wy)/D
u =  (vx*wy - vy*wx)/D
' v = perp(ux, uy, wx, wy)/D
v = (ux*wy - uy*wx)/D

if u < 0.0 then return false
if v < 0.0 or v > 1.0 then return false

return true
endfunc

procedure GLOOM_PushOut(&x#, &z#, r#)
steps = 0
do
collision = false
for i = 0 to rc_WallCount - 1
if CLInt(x, z, r, rc_Walls[i][0], rc_Walls[i][1], rc_Walls[i][2], rc_Walls[i][3])
collision = true
endif
next
steps = steps + 1
until collision = false or steps = 4
endproc

function CLInt(&cx#, &cy#, cr#, lx1#, ly1#, lx2#, ly2#)
c#[] = [cx - lx1, cy - ly1]
l#[] = [lx2 - lx1, ly2 - ly1]
lineLen# = V_Size(l)
param#
' p is the clost point ON the line to c.
p#[] = V_ProjectGet2(c, l, param)

' is the projection on the line?
if param >= 0.0 and param <= lineLen
dv#[] = V_SubGet(c, p)
if V_Size(dv) < cr
' dv is actually the normal of the line in the correct direction.
' so we can get the corrected position.
_V_Normalize dv
cx = lx1 + p[0] + dv[0]*cr
cy = ly1 + p[1] + dv[1]*cr
return true
else
return false
endif
' check closest distance to vertices.
else
' closest to first vertex?
if param < 0.0
ed# = DistanceF(cx, cy, lx1, ly1)
if ed < cr
' push out.
dv#[] = [cx - lx1, cy - ly1]
_V_Normalize dv
cx# = lx1 + dv[0]*cr
cy# = ly1 + dv[1]*cr
return true
else
return false
endif
' cosest to second vertex.
else
ed# = DistanceF(cx, cy, lx2, ly2)

if ed < cr
dv#[] = [cx - lx2, cy - ly2]
_V_Normalize dv
cx# = lx2 + dv[0]*cr
cy# = ly2 + dv[1]*cr
return true
else
return false
endif
endif
return false
endif

endfunc

function V_ProjectGet2#[](&u#[], &v#[], &p#)
n#[] = V_NormalizeGet(v)
s# = V_Dot(u, n)
p = s
return [n[0]*s, n[1]*s]
endfunc
« Last Edit: May 13, 2017 by Marcus »
.\\\opz

Rick3137

  • Sr. Member
  • ****
  • Posts: 342
  • May the Force be with You
    • View Profile
    • Rick's Programs
Re: Line/circle collision
« Reply #6 on: May 13, 2017 »
   Nice work.

   Looks like a good start for a game. May take awhile.

Marcus

  • Administrator
  • Hero Member
  • *****
  • Posts: 542
    • View Profile
Re: Line/circle collision
« Reply #7 on: May 13, 2017 »
I implemented what I wrote and have attached an example. I temporarily removed collision handling (because I haven't adjusted it to the new system yet), but you can still move around in a pretty vast maze. I created the maze in a silly editor that's also included.

It runs pretty slow for now, but lots can be done about that.

I realize I've left the original topic and transformed it into raycasting.

Edit:  Fixed the collision handling.
« Last Edit: May 14, 2017 by Marcus »
.\\\opz

Rick3137

  • Sr. Member
  • ****
  • Posts: 342
  • May the Force be with You
    • View Profile
    • Rick's Programs
Re: Line/circle collision
« Reply #8 on: May 13, 2017 »
 Wow!
 I like the new map editor.

 Here's a quick map I made...

Code: [Select]
123
2 5 3 2
7 1 3 2
7 1 9 4
9 4 11 5
11 5 13 2
13 2 16 1
16 1 20 2
20 2 22 5
22 5 25 4
25 4 27 1
27 1 30 2
30 2 31 5
31 5 29 8
29 8 27 7
27 7 24 7
24 7 23 9
23 9 24 12
24 12 26 12
26 12 29 10
29 10 30 11
31 14 30 11
31 14 30 17
30 17 27 18
27 18 26 20
26 20 28 23
28 23 30 24
30 24 31 28
31 28 29 30
29 30 25 31
25 31 21 30
21 30 18 28
18 28 15 29
15 29 12 31
12 31 10 30
10 30 9 28
9 28 8 26
8 26 10 23
10 23 13 22
13 22 12 20
12 20 10 19
10 19 7 20
7 20 8 22
8 22 7 24
7 24 6 26
6 26 7 29
7 29 5 30
5 30 3 27
3 27 4 23
4 23 2 20
2 20 4 16
4 16 7 15
7 15 8 14
8 14 6 12
6 12 4 13
4 13 1 11
1 11 3 8
2 5 3 8
7 4 6 5
6 5 5 7
5 7 6 9
6 9 8 10
8 10 11 9
11 9 12 7
12 7 9 6
9 6 7 4
16 3 15 4
15 4 16 8
16 8 14 11
14 11 11 12
11 12 10 15
10 15 12 17
12 17 15 16
15 16 15 12
15 12 18 10
18 10 20 7
20 7 19 4
18 6 19 4
18 6 17 5
17 5 16 3
21 13 23 14
23 14 26 14
26 14 27 16
27 16 24 19
24 19 22 17
22 17 20 15
20 15 18 16
18 16 17 19
17 19 16 18
16 18 17 14
17 14 20 11
20 11 22 11
22 11 23 12
23 12 21 13
14 24 12 24
12 24 11 26
11 26 12 28
12 28 15 28
15 28 17 26
17 26 18 24
18 24 17 21
15 20 17 21
15 20 16 23
14 24 16 23
23 22 20 24
20 24 19 26
19 26 23 29
23 29 25 28
25 28 23 26
23 26 22 25
22 25 24 24
24 24 26 26
26 26 28 25
28 25 25 21
25 21 24 20
24 20 23 22
28 27 27 28
27 28 27 29
27 29 29 28
29 28 28 27
20 17 19 19
19 19 20 21
20 21 22 20
22 20 20 17


Marcus

  • Administrator
  • Hero Member
  • *****
  • Posts: 542
    • View Profile
Re: Line/circle collision
« Reply #9 on: May 14, 2017 »
I'll probably rewrite this stuff in C to speed it up. Anyhow, the name GLOOM is from a first person shooter that was relased on Amiga many, many years ago. Amiga users were so jelly of Doom on the PC :) That's probably what could be expected if I make a library of it.

GLOOM gameplay: https://www.youtube.com/watch?v=uRk-TX2RaOs
.\\\opz

Marcus

  • Administrator
  • Hero Member
  • *****
  • Posts: 542
    • View Profile
Re: Line/circle collision
« Reply #10 on: May 19, 2017 »
Here's another one where I've rewritten some of the "hard work" in C and made an extension.

Floor, ceiling and sprites/billboards coming soon.
« Last Edit: May 19, 2017 by Marcus »
.\\\opz

Marcus

  • Administrator
  • Hero Member
  • *****
  • Posts: 542
    • View Profile
Re: Line/circle collision
« Reply #11 on: May 20, 2017 »
Floor and ceiling added, just modifications of the original raycaster stuff for taller walls. Couldn't translate it to C easily, since it was written in pure bytecode :D
.\\\opz

Rick3137

  • Sr. Member
  • ****
  • Posts: 342
  • May the Force be with You
    • View Profile
    • Rick's Programs
Re: Line/circle collision
« Reply #12 on: May 21, 2017 »
  Pure Inspiration...
  Works good.
  I like your gloom.dll idea. Some day I need to learn how to do that. Could take awhile.
  I think I would have to use Microsoft's free CSharp compiler. I managed to get it installed on my computer I think it makes DLLs. I have tried to install the c++ compiler, but I did something wrong and got stuck.
  I have a Code Blocks C compiler but I doubt it is compatible with NaaLaa.
 

Marcus

  • Administrator
  • Hero Member
  • *****
  • Posts: 542
    • View Profile
Re: Line/circle collision
« Reply #13 on: May 21, 2017 »
  Pure Inspiration...
  Works good.
  I like your gloom.dll idea. Some day I need to learn how to do that. Could take awhile.
  I think I would have to use Microsoft's free CSharp compiler. I managed to get it installed on my computer I think it makes DLLs. I have tried to install the c++ compiler, but I did something wrong and got stuck.
  I have a Code Blocks C compiler but I doubt it is compatible with NaaLaa.

Yeah, I haven't updated the "extension builder stuff" in a while, sorry. Will do when I get the time. I don't think it's possible to use anything but Visual Studio and C/C++ :(  You have to link to a library written in C and include a header filled with macros and stuff.

I'll create a new thread for what I've been posting here.
.\\\opz