Stages :
the bacground was moving from right to left
Stage 1. Dangerous Mission
click each image to zoom in Yoke to left to shoot Yoke to center to shoot the background was moving toward you
Stage 2. Devil's Shadow
Update There are some updates, mainly on Stage 2. You may download [ devil_triangle_v3.zip ]
Code:
'==============================================================================================
'THE DEVIL'S TRIANGLE v3
'Stage 1. Dangerous Mission
'Stage 2. Devil's Shadow
'
'Control Keys :
'- UP, DOWN move the plane (stage 1)
'- UP, LEFT,RIGHT move the jet's yoke (stage 2)
'- SPACE BAR shoot (stage 2)
'- ESC quit
'- M ON/OFF music
'- ENTER continue
'
'Acknowledgement :
'- s3d library, thanx to Marcus for push and pop transformation
'
'3D Model :
'- Voxel Plane by maxparata https://maxparata.itch.io/voxel-plane?download
'- Ball by @Spacemonkeyl_1458647 https://www.printables.com/model/651543-low-poly-ball/files
'
'Images and Sound :
'- Background image https://images.app.goo.gl/J2SdZoV6YyNRPXBM6
'- Cool Slow Rock by Nick Valerson https://pixabay.com/music/search/rock%20background%20music/
'- Fighter Jet Cockpit https://images.app.goo.gl/ouzXGwgNkwcMgCkc7
'- Yoke steering wheel https://images.app.goo.gl/2k42XiBYfLt2Nfk16
'- Skull island https://images.app.goo.gl/qBy2hv1UtFmnRXV98
'
'DISCLAIMER
'This tiny game is a work of fiction.
'It is a proof of 3D game concept using s3d library.
'It is not intended for commercial use and not for sale
'No person or entity associated with this game received payment
'or anything of value, or entered into any agreement,
'in connection with any game assets used in this game.
'Names, characters, places, events and incidents
'are either the products of the author’s imagination
'or used in a fictitious manner.
'Any resemblance to actual persons,
'living or dead, or actual events is purely coincidental.
'
'===============================================================================================
'----------------
' INITIALIZATION
'----------------
#win32
include "s3d.n7"; S3D_SetView(primary, rad(45), 0.1, 50)
include "plane/s3d_addon.n7"
include "plane/transform.n7"
set window "The Devil's Triangle",800,400,false
set redraw off
randomize clock()
'color definition
white = [255,255,255]
black = [0,0,0]
gray = [200,200,200]
red = [255,0,0,100]
yellow = [255,255,0,120]
'other initial value
info = []
info.score = 0
info.lifes = 5
info.font_ = loadfont("plane/meiryo24")
'------------
' DISCLAIMER
'------------
set color black; cls; set color white; set caret 50,50; set font 0
wln "DISCLAIMER"
wln
wln "This tiny game is a work of fiction."
wln "It is a proof of 3D game concept using s3d library."
wln "It is not intended for commercial use and not for sale"
wln "No person or entity associated with this game received payment"
wln "or anything of value, or entered into any agreement,"
wln "in connection with any game assets used in this game."
wln "Names, characters, places, events and incidents"
wln "are either the products of the author’s imagination"
wln "or used in a fictitious manner."
wln "Any resemblance to actual persons,"
wln "living or dead, or actual events is purely coincidental."
wln
wln "Press ENTER to continue"
redraw
do; wait 1; until keydown(KEY_RETURN,true)
'opening title
words = []
words[1] ="THE DEVIL'S TRIANGLE"
words[2] =""
words[3] ="In December 1945, Flight 19 - Avenger Torpedo Bombers"
words[4] ="disappeared over the Bermuda Triangle."
words[5] ="The Bermuda Triangle is known as The Devil's Triangle"
words[6] ="It is on an area bounded by Florida,Bermuda and Puerto Rico."
words[7] ="And now, you are assigned to investigate the area."
words[8] ="Beware, it is a dangerous area !"
words[9] =""
words[10] =""
words[11] =""
words[12] =""
words[13] =""
words[14] ="Please proceed to military airbase"
'--------
' TITLE
'--------
'text animation of opening title
set font info.font_
play music plane.music_,1 'loop
set music volume plane.music_, 0.25
for i = height(primary) to 30
set color black; cls; set color white
set caret width(primary)/2,i
for j = 1 to 14
center words[j]
next
redraw
fwait 30
next
'just an animation of 3D plane
plane.y = 2
do
set color black; cls; set color white; S3D_Clear()
set caret width(primary)/2,i
for j = 1 to 14
center words[j]
next
S3D_Translate(-1, 0, 5)
if plane.x < 7 then
plane.x = plane.x + 0.03
else
plane.x = -2
plane.y = rnd(0,2)
plane.rotype = 1
endif
plane.y = plane.y - 0.003
plane.rotate = (plane.rotate + 30*0.005)%360
S3D_Draw(plane.x,plane.y,plane.z,plane.rotype,plane.rotate,plane.model)
'----------------------------
' STAGE 1. DANGEROUS MISSION
'----------------------------
set color black; cls; set color white
set caret 50,50
wln "Stage 1 : DANGEROUS JOURNEY"
wln
wln "Press UP or DOWN continuously"
wln "Just avoid bombs as long as possible"
wln "Till you reach the devil's island"
wln
wln "Press ENTER to continue"
redraw
do;wait 1; until keydown(KEY_RETURN,true)
do
set color black; cls; set color white; S3D_Clear()
if keydown(KEY_ESCAPE,true) then end
'background music
if keydown(KEY_M,true)
plane.unmute = not plane.unmute
if plane.unmute then
play music plane.music_,1
set music volume plane.music_, 0.5
else
stop music plane.music_
endif
endif
'information
set color white
set caret 5,10
if plane.unmute then
wln "Background Music : ON"
else
wln "Background Music : OFF"
endif
wln "Score : "+int(info.score) ; info.score = info.score + 0.01
if info.lifes <0 then
do
set caret 5,height(primary)-50; wln "Insert COIN to continue (Y/N)";redraw
if keydown(KEY_N,true) then end
if keydown(KEY_Y,true) then info.lifes = 5
wait 2
until info.lifes = 5
endif
wln "Lifes : "+info.lifes
'x-axis, y-axis
'set color gray
'cx = width(primary)/2
'cy = height(primary)/2
'draw line cx,0,cx,cy*2
'draw line 0,cy,cx*2,cy
'plane control
if keydown(KEY_UP,true) then
if plane.y > -5 then
plane.y = plane.y - 0.08
plane.rotate = (plane.rotate + 90*0.03)%360
endif
endif
if keydown(KEY_DOWN,true) then
if plane.y < 5 then
plane.y = plane.y + 0.08
plane.rotate = (plane.rotate - 90*0.03)%360
endif
endif
if plane.y <= -5 then plane.y = 4
if plane.y >= 5 then plane.y = -4
' Move everything 10 units into the screen, it affect all other drawing
S3D_Translate(0, 0, 10)
S3D_Draw(plane.x,plane.y,plane.z,plane.rotype,plane.rotate,plane.model)
'Ball
for i = 1 to ball.count
ball[i].rotate = (ball[i].rotate + 30*0.03)%360
if ball[i].x >= -10 then
ball[i].x = ball[i].x - ball[i].speed
else
ball[i].x = rnd(7,10)
ball[i].y = rnd(-4,4)
ball[i].speed = rnd(3,5)/100
endif
S3D_Draw(ball[i].x,ball[i].y,ball[i].z,ball[i].rotype,ball[i].rotate,ball[i].model)
'Explosion
dbp = sqr(pow((ball[i].x-plane.x),2)+pow((ball[i].y-plane.y),2))
if dbp<=1 then
temp = ball[i].x
for j = 1 to ball.count
ball[j].x = rnd(7,10) 'reset position
next
set caret 5,height(primary)-50; wln "Press ENTER to continue"
S3D_Draw(temp,plane.y,explosion.z,explosion.rotype, explosion.rotate,explosion.model)
redraw
do; wait 1; until keydown(KEY_RETURN,true)
info.lifes = info.lifes - 1
endif
next
redraw
wait 1
until info.score >= 50
set caret 5,height(primary)-60
wln "Be ready for Stage 2"
wln "Press ENTER to continue"
redraw
do; wait 1; until keydown(KEY_RETURN,true)
'----------------------------
' STAGE 2. DEVIL'S SHADOW
'----------------------------
set color black; cls; set color white
set caret 50,50;
wln "Stage 2 : DEVIL'S SHADOW"
wln
wln "There are 3 possible enemy's positions"
wln " enemy on the left, LEFT then shoot with SPACE BAR"
wln " enemy at the center, UP then shoot with SPACE BAR"
wln " enemy on the right, RIGHT then shoot with SPACE BAR"
wln
wln "Shoot when an enemy is close enough"
wln "but not too close"
wln
wln
wln
wln "Press ENTER to continue"
redraw
do;wait 1; until keydown(KEY_RETURN,true)
do
set color black; cls; set color white; S3D_Clear()
if keydown(KEY_ESCAPE,true) then end
'background music
if keydown(KEY_M,true)
plane.unmute = not plane.unmute
if plane.unmute then
play music plane.music_,1
set music volume plane.music_, 0.5
else
stop music plane.music_
endif
endif
'control
if keydown(KEY_RIGHT,true) then
jet.angle = rad(15)
jet.position = "right"
elseif keydown(KEY_LEFT,true) then
jet.angle = rad(-15)
jet.position = "left"
elseif keydown(KEY_UP,true) then
jet.angle = rad(0)
jet.position = "center"
endif
'enemy's plane
if plane.x1 = 0 then
plane.position1 = "center"
elseif plane.x1 > 0 then
plane.position1 = "right"
elseif plane.x1 < 0 then
plane.position1 = "left"
else
plane.position1 = ""
endif
if plane.x2 = 0 then
plane.position2 = "center"
elseif plane.x2 > 0 then
plane.position2 = "right"
elseif plane.x2 < 0 then
plane.position2 = "left"
else
plane.position2 = ""
endif
if plane.x3 = 0 then
plane.position3 = "center"
elseif plane.x3 > 0 then
plane.position3 = "right"
elseif plane.x3 < 0 then
plane.position3 = "left"
else
plane.position3 = ""
endif
'enemy's plane animation
S3D_Translate(translate.x, 0, 10)
if plane.z1 >= -7 then
plane.z1 = plane.z1 -0.1
info.status =""
elseif plane.z1 < -7 then
plane.x1 = rnd(-3,3)
plane.y1 = rnd(-2,0)
plane.z1 = 10
info.lifes = info.lifes - 1
set color red
draw rect 0,0,width(primary),height(primary),1
set color white
set caret 10,10
wln "You've been attacked !"
wln "You lost your life"
wln
wln "Press ENTER to continue"
redraw
do; wait 1 ; until keydown(KEY_RETURN,true)
endif
if (plane.z1 >-7 and plane.z1<-3) then
info.status = "SHOOT NOW !!!!"
tempx1 = plane.x1
tempy1 = plane.y1
tempz1 = plane.z1
if keydown(KEY_SPACE,true) and jet.position = plane.position1 then
info.score = info.score + 1
plane.x1 = rnd(-3,3)
plane.y1 = rnd(-2,0)
plane.z1 = 10
info.shot = "plane1"
endif
else
info.status = ""
endif
if plane.z2 >= -7 then
plane.z2 = plane.z2 -0.1
info.status =""
elseif plane.z2 < -7 then
plane.x2 = rnd(-3,3)
plane.y2 = rnd(-2,0)
plane.z2 = 20
info.lifes = info.lifes - 1
set color red
draw rect 0,0,width(primary),height(primary),1
set color white
set caret 10,10
wln "You've been attacked !"
wln "You lost your life"
wln
wln "Press ENTER to continue"
redraw
do; wait 1 ; until keydown(KEY_RETURN,true)
endif
if (plane.z2 >-7 and plane.z2<-3) then
info.status = "SHOOT NOW !!!!"
tempx2 = plane.x2
tempy2 = plane.y2
tempz2 = plane.z2
if keydown(KEY_SPACE,true) and jet.position = plane.position2 then
info.score = info.score + 1
plane.x2 = rnd(-3,3)
plane.y2 = rnd(-2,0)
plane.z2 = 20
info.shot = "plane2"
endif
else
info.status = ""
endif
if plane.z3 >= -7 then
plane.z3 = plane.z3 -0.1
info.status =""
elseif plane.z3 < -7 then
plane.x3 = rnd(-3,3)
plane.y3 = rnd(-2,0)
plane.z3 = 30
info.lifes = info.lifes - 1
set color red
draw rect 0,0,width(primary),height(primary),1
set color white
set caret 10,10
wln "You've been attacked !"
wln "You lost your life"
wln
wln "Press ENTER to continue"
redraw
do; wait 1 ; until keydown(KEY_RETURN,true)
endif
if (plane.z3 >-7 and plane.z3<-3) then
info.status = "SHOOT NOW !!!!"
tempx3 = plane.x3
tempy3 = plane.y3
tempz3 = plane.z3
if keydown(KEY_SPACE,true) and jet.position = plane.position3 then
info.score = info.score + 1
plane.x3 = rnd(-3,3)
plane.y3 = rnd(-2,0)
plane.z3 = 10
info.shot = "plane3"
endif
else
info.status = ""
endif
'Draw and Render
Draw(back.island,width(back.island)/2,height(back.island)/2-20,back.scale,jet.angle)
S3D_Draw(plane.x1,plane.y1,plane.z1,plane.rotype,plane.rotate,plane.model)
S3D_Draw(plane.x2,plane.y2,plane.z2,plane.rotype,plane.rotate,plane.model)
S3D_Draw(plane.x3,plane.y3,plane.z3,plane.rotype,plane.rotate,plane.model); S3D_Render()
if info.shot = "plane1" then
S3D_Draw(tempx1,tempy1,tempz1,0,0,explosion.model)
elseif info.shot = "plane2" then
S3D_Draw(tempx2,tempy2,tempz2,0,0,explosion.model)
elseif info.shot = "plane3" then
S3D_Draw(tempx3,tempy3,tempz3,0,0,explosion.model)
endif
Draw(jet.cockpit,width(primary)/2+10,230,1.6,jet.angle)
Draw(jet.yoke,width(primary)/2+10,360,1,jet.angle)
'information
set color white
set caret 5,10
if plane.unmute then
wln "Background Music : ON"
else
wln "Background Music : OFF"
endif
wln "Score : "+int(info.score)
wln "Lifes : "+info.lifes
wln
wln info.status
if info.shot="plane1" or info.shot="plane2" or info.shot="plane3" then
wln "Press ENTER to continue"
redraw
do; wait 1; until keydown(KEY_RETURN,true)
info.shot = ""
endif
if info.lifes <0 then
do
set caret 5,height(primary)-50; wln "Insert COIN to continue (Y/N)";redraw
if keydown(KEY_N,true) then end
if keydown(KEY_Y,true) then info.lifes = 3
wait 2
until info.lifes = 3
endif
redraw
wait 1
until info.score > 20
set caret 5,height(primary)-150
wln "Even though you've gone so far"
wln "The mystery is still unsolved"
wln "..."
wln
wln "Press ESCAPE to quit"
redraw
do; wait 1; until keydown(KEY_RETURN,true)
Question #1
As you may see in the images above, I found a strange thing with the movement of the pyramid.
When I pressed UP or DOWN, the pyramid followed the plane direction.
What should be changed in the code ?
Question #2
The initial value of
plane.y = 0
pyramid.y = 6
But why are the plane and the pyramid in the same horizontal line at the beginning of the game ?
Code:
'=====================================================
'The Devil's Triangle
'
'3D Model :
'Voxel Plane assets by maxparata
'https://maxparata.itch.io/voxel-plane?download
'======================================================
'----------------
' INITIALIZATION
'----------------
include "s3d.n7"; S3D_SetView(primary, rad(45), 0.1, 50)
set window "The Devil's Triangle",800,400,false
set redraw off
'color definition
white = [255,255,255]
black = [0,0,0,120]
gray = [200,200,200]
I need to calculate and display the convex hull of 2D polygons in the editor for that 3d thing, so I implemented a quick (as in "divide and conquer") algorithm for it. I remember writing a quick algorithm for the convex hull of a set of random points in 3D at the university, which is a bit trickier.
If you ever need to calculate the convex hull for a polygon or a bunch of points, you can use this
Code:
' Convex hull test
' ----------------
set window "test", 640, 480
set redraw off
do
set color 0, 0, 0
cls
' Create 100 random points.
points = []
for i = 1 to 100
a = rnd()*2*PI
r = rnd(200)
points[sizeof(points)] = 320 + cos(a)*r
points[sizeof(points)] = 240 + sin(a)*r
next
' Draw points.
set color 255, 255, 255
pcount = sizeof(points)/2
for i = 0 to pcount - 1
draw pixel points[i*2], points[i*2 + 1]
next
' Display and wait one second.
redraw
wait 1000
' Calculate convex hull and display it.
hull = ConvexHull(points)
draw poly hull
set caret width(primary)/2, 4
center "Press space bar to continue ..."
redraw
while not keydown(KEY_SPACE, true) fwait 60
loop
' ConvexHull
' ----------
' Calculate the convex hull for a set of points in an array [x0, y0, x1, y1 ..], return as a polygon
' in the same format.
function ConvexHull(points)
pcount = sizeof(points)/2
xminIndex = 0; xmaxIndex = 0
for i = 1 to pcount - 1
x = points[i*2]
if x < points[xminIndex*2] xminIndex = i
if x > points[xmaxIndex*2] xmaxIndex = i
next
lpoints = []; rpoints = []
for i = 0 to pcount - 1
if i <> xminIndex and i <> xmaxIndex
cp = CrossProd(points[xminIndex*2], points[xminIndex*2 + 1],
points[xmaxIndex*2], points[xmaxIndex*2 + 1],
points[i*2], points[i*2 + 1])
if cp < 0
lpoints[sizeof(lpoints)] = points[i*2]
lpoints[sizeof(lpoints)] = points[i*2 + 1]
elseif cp > 0
rpoints[sizeof(rpoints)] = points[i*2]
rpoints[sizeof(rpoints)] = points[i*2 + 1]
endif
endif
next
hull = []
hull[sizeof(hull)] = points[xminIndex*2]
hull[sizeof(hull)] = points[xminIndex*2 + 1]
HullRec(hull, lpoints, points[xminIndex*2], points[xminIndex*2 + 1], points[xmaxIndex*2], points[xmaxIndex*2 + 1])
hull[sizeof(hull)] = points[xmaxIndex*2]
hull[sizeof(hull)] = points[xmaxIndex*2 + 1]
HullRec(hull, rpoints, points[xmaxIndex*2], points[xmaxIndex*2 + 1], points[xminIndex*2], points[xminIndex*2 + 1])
return hull
function HullRec(hull, points, x0, y0, x1, y1)
if not sizeof(points) return
pcount = sizeof(points)/2
maxd = 0; maxdIndex = -1
for i = 0 to pcount - 1
x = points[i*2]; y = points[i*2 + 1]
d = LinePointDist(x0, y0, x1, y1, x, y)
if d > maxd
maxd = d
maxdIndex = i
endif
next
npoints = []
for i = 0 to pcount - 1
if i <> maxdIndex
x = points[i*2]; y = points[i*2 + 1]
cp = CrossProd(x0, y0, points[maxdIndex*2], points[maxdIndex*2 + 1], x, y)
if cp < 0
npoints[sizeof(npoints)] = x
npoints[sizeof(npoints)] = y
endif
endif
next
if sizeof(npoints)
HullRec(hull, npoints, x0, y0, points[maxdIndex*2], points[maxdIndex*2 + 1])
endif
hull[sizeof(hull)] = points[maxdIndex*2]
hull[sizeof(hull)] = points[maxdIndex*2 + 1]
npoints = []
for i = 0 to pcount - 1
if i <> maxdIndex
x = points[i*2]; y = points[i*2 + 1]
cp = CrossProd(points[maxdIndex*2], points[maxdIndex*2 + 1], x1, y1, x, y)
if cp < 0
npoints[sizeof(npoints)] = x
npoints[sizeof(npoints)] = y
endif
endif
next
if sizeof(npoints)
HullRec(hull, npoints, points[maxdIndex*2], points[maxdIndex*2 + 1], x1, y1)
endif
endfunc
This is not meant to be a proper simulation (as you will see if you run it ), but just an experiment with the terrific circle-line functions that Marcus provided a while back. I've used the functions as they were originally written by Marcus, with one small alteration to the polygon function, where I have added a fifth argument to allow me to specify a point around which the polygon is rotated, rather than the center point of the polygon (I needed this for the 2 flippers).
There a few values that can be altered in the code to change the way that the ball reacts to certain lines - I've marked some of these as "arbitrary values", and I'm sure changing these will make for a smoother game, but I've decided to move on to a new project.
Control the flippers with the A and D keys, and launch the ball using the UP arrow.
Code:
' Experiment.
set window "PINBALL", 480, 640
set redraw off
#win32
visible score = 0
' List of lines that objects can collide with.
left_flipper = []
right_flipper = []
l_flipper = Polygon([0,0,10,-10,60,30,60,40], 140,580, true,[0,0])
r_flipper = Polygon([0,0,-10,-10,-60,30,-60,40], 300,580, true,[0,0])
'=============================================================================
'Note -added fifth argument to Polygon - 0 rotates around center point, or
'use a 2 part table to rotate around any point in the polygon - i.e. [32,34]
' to rotate around the fourth point in the polygon array here : -
'l_flipper = Polygon([0,0,10,0,32,24,32,34,22,34,0,10], 320, 240, true,[32,34])
'==============================================================================
l_flipper.AddTo(left_flipper)
left_flipper_timer = 0
left_ang = 0
'triangles sticking out of side - not bouncing
lines[sizeof(lines)] = Line(0,380,40,380)
lines[sizeof(lines)] = Line(0,310,40,380)
lines[sizeof(lines)] = Line(440,380,400,380)
lines[sizeof(lines)] = Line(400,380,440,310)
PushOut(obj, right_flipper)
if obj.pdy < 0
if r_flipper.Angle() <> 0
obj.dy = - 10
right_ang = angle_rad(r_flipper.trans[2][0],r_flipper.trans[2][1],r_flipper.trans[1][0],r_flipper.trans[1][1])
right_vecs = get_vecs(right_ang)
obj.dx = obj.dx + right_vecs[0] * 32'arbitrary figure
endif
endif
'==================================
PushOut(obj, bouncers)' make them bounce a little
if obj.pdx <> 0 or obj.pdy <> 0
obj.dx = obj.dx + obj.pdx*12'arbitrary figure
obj.dy = obj.dy + obj.pdy*12 'arbitrary figure
endif
PushOut(obj, lines)
'
if obj.y < 180 and obj.x > 240 and obj.dx < 0' help with initial lauch of ball
if obj.pdx <> 0 or obj.pdy <> 0
obj.dx = obj.dx + obj.pdx*4'arbitrary figure
endif
endif
if obj.y < 180 and obj.x < 240 ' help with initial lauch of ball
if obj.pdx <> 0 or obj.pdy <> 0
obj.dx = obj.dx + obj.pdx*0.3'arbitrary figure
obj.dy = obj.dy + obj.pdy*1
endif
endif
' obj.pdx and obj.pdy has now been set to the average "push direction" caused by all lines
' pushing the object around.
' Push direction y < 0 means the object is being pushed UP. In that case, set dy to 0.
if obj.pdy < 0
' If push direction y < -0.25, let the player jump.
if obj.pdy < -0.25 and keydown(KEY_UP, true) and obj.x >= 455
obj.dy = -14
endif
endif
' Apply gravity.
obj.dy = min(obj.dy + 0.1, 6)
' So ... stuff to dx.
obj.dx = obj.dx + obj.pdx*0.25 ' I have no idea
obj.dx = obj.dx*0.95
set color 0, 0, 0
cls
set color 255, 255, 255
DrawLines(lines)
DrawLines(circles)
DrawLines(bouncers)
DrawLines(left_flipper)
DrawLines(right_flipper)
obj.Draw()
set caret 20,10
set justification left
write "SCORE : " + score;wln
' set caret 460,10
' set justification right
' write "FPS = " + str(fps);wln
####### FPS calc ############################
endtime = clock()
frametime = frametime + endtime - starttime
if frametime > 1000 # 1 second
fps = framecount
framecount = 0
frametime = 0
if fps < min_fps then min_fps = fps
if fps > max_fps then max_fps = fps
endif
################################################
wend
function DrawLines(lines)
foreach ln in lines draw line ln[0], ln[1], ln[2], ln[3]
endfunc
function Object(x, y, r)
return [x: x, y: y, r: r, rsqr: r*r, pdx: 0, pdy: 0,
Draw: function(); draw ellipse .x, .y, .r, .r, false; endfunc]
endfunc
' Pushout
' -------
function PushOut(obj, lines)
tests = 4
obj.pdx = 0
obj.pdy = 0
for i = 1 to tests
col = false
foreach ln in lines
dp = max(0, min(ln[6], (obj.x - ln[0])*ln[4] + (obj.y - ln[1])*ln[5]))
px = ln[0] + dp*ln[4]; py = ln[1] + dp*ln[5]
dx = obj.x - px; dy = obj.y - py
d = dx*dx + dy*dy
if d < obj.rsqr
k = 1/sqr(d)
obj.x = px + dx*k*obj.r
obj.y = py + dy*k*obj.r
obj.pdx = obj.pdx + dx*k
obj.pdy = obj.pdy + dy*k
col = true
endif
next
if not col break
next
if obj.pdx or obj.pdy
k = 1/sqr(obj.pdx*obj.pdx + obj.pdy*obj.pdy)
obj.pdx = obj.pdx*k
obj.pdy = obj.pdy*k
endif
endfunc
' Polygon
' -------
' Return polygon at position x, y.
' Polygon
' -------
' Return polygon at position x, y.
'function Polygon(points, x, y, closed,rotation_point_x,rotation_point_y)
function Polygon(points, x, y, closed,rotation_point)
'========================================================================
'Note - added fifth argument to Polygon - 0 rotates around center point, or
'use a 2 part table to rotate around any point in the polygon - i.e. [32,34]
' to rotate around the fourth point in the polygon array here :-
'l_flipper = Polygon([0,0,10,0,32,24,32,34,22,34,0,10], 320, 240, true,[32,34])
'========================================================================
p = [trans: unset, org: [], x: x, y: y, a: 0, cx:0, cy: 0]
pcount = sizeof(points)/2
centerX = 0
centerY = 0
if closed n = pcount - 1
else n = pcount - 2
for i = 0 to n
j = (i + 1)%pcount
p.org[sizeof(p.org)] = Line(
points[i*2], points[i*2 + 1],
points[j*2], points[j*2 + 1])
next
for i = 0 to pcount - 1
if rotation_point = 0
p.cx = p.cx + points[i*2]; p.cy = p.cy + points[i*2 + 1]
else
p.cx = rotation_point[0] * pcount 'rotation_point_x
p.cy = rotation_point[1] * pcount ' rotation_point_y
endif
next
Building a level, walls; floors and ceilings, I can do... but I get a little confused with placing items... I can place item on the ceiling and floors ok. But the "indexes" for the items I am not all that familiar. Do the "item" indexes have to be the same as the image "indexes"?
Would there be a RC PDF squirreled away on some drive per chance?
This is just a walls, floor and ceiling layout of the first level modeled after the actual Wolf3D game... This is just a navigable concept level of 64x64 tiles... just to see how N7 copes performance wise...
I will probably use a different tileset for the complete game (assuming I can get that far... lol)... It would be a good idea not to step on Apogee's toes... lol
Of course, the usual constructive criticisms and suggestions, are always welcome....
Disclaimer
No person or entity associated with this game received payment or anything of value, or entered into any agreement,
in connection with the depiction of the ancient egyptian culture and with any game assets used in this game. \
No mummies were harmed in the making of this game. Any similarity to any person living or dead is coincidental
Stage
Stage 1. Sand Desert in s3d
First thing first, find a hieroglyph magic spell. Without the spell, you can't eliminate a mummy.
Cast the spell in a relative close distance. But, don't too close to the mummy.
control key : SPACE BAR, Mouse, S
Stage 2. Maze inside the Pyramid in wolf3d
The maze grid size is small, so you don't need a map.
The maze is auto-generated using random maze algorithm.
control key : LEFT, RIGHT, UP, DOWN, SPACE BAR
-. Find a key to hidden knowledge
-. Enjoy your egyptian treasures
-. Taste the magical amulet
-. Wear a super diamond
-. Search for the Pharaoh's Sceptre
Hints :
1. Turn on your best sound system. Experience the creepy atmosphere. Don't play this game after midnight.
2. Don't skip or press ESC too soon, just enjoy every scene.
Note :
This game uses new library of s3d. It's really injected new fresh energy into the classic horror theme with its contemporary and somewhat experimental approach to the 3D world. Thanks to Marcus for providing feedback especially on how to put a mummy and example on how to use heightmap using s3d library and thanks to Johnno for MazeGen
If memory serves correctly, at one time, you stated that Wolf3D did not have an editor... I have noticed that the command structure for Wolf3D is quite similar to that of N6's Raycaster. Is it at all possible that the RC editor may be modified for Wolf3D use? But, then again, what about using the Tilemap Editor? Even if it is to just create the a "map[]" file to be read by Wolf3D... Just a thought or two... (Ok... You can stop chuckling now... *sighh*)
I made a very crude "platformer" 'map' editor, using a language that shall not be named, but it is quite limited in what it can do... but, what it does do, is create a text file of the level map. I suppose, assuming I have the ability to do so, I could try to modify the output file to reflect the same structure "map = []" uses... Warning: This will be a "stretch" for me... I am not certain that I can properly convert the base program to N7... If I can, then I shall discuss the limitations in more detail... Please do not hold your breath whilst you wait.... lol
I just thought I'd post an example of the current state of that 3d thing I'm working on. It's just an executable where you walk around in a level created with the editor. No source code or editor included this first time. There are still no "sub sectors", so a single sector always have the same floor and wall height. Next time I promise you more advanced rooms and some decoration meshes.
Walk with WASD and look around with the mouse. There is a settings menu where you can change some graphical things and mouse sensitivity (the menu pops up as soon as you start, and you can bring it up again with the escape key).
Edit You will see that the walls "wiggle" when you walk along them at close range. That's an effect caused by lerping instead of doing fully perspective correct texture mapping. I may improve that the next time I update the S3D library. But that will have to wait until this engine is ready and I've made a game with it.