Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Devil's Triangle (The Game)
#1
THE DEVIL'S TRIANGLE v3

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]

'plane
plane = []
plane.model = S3D_LoadMesh("plane/Plane01.obj", 0.5,-0.5,0.5, false)
plane.rotate = 30
plane.rotype = 1
plane.x = -5 ; plane.y = 0 ; plane.z = 0
plane.music_ = loadmusic("plane/rock.wav")
plane.unmute   = true

'explosion
explosion = []
explosion.model = S3D_LoadMesh("plane/explosion.obj",1,-1,1,false)
explosion.rotate = 0
explosion.rotype = 0
explosion.x = -5; explosion.y = 0 ; explosion.z = 0

'ball
ball = []
ball.count = 3
for i = 1 to ball.count
    ball[i] = []
    ball[i].model = S3D_LoadMesh("plane/icoball.obj",0.25,-0.25,0.25,false)
    ball[i].rotate = 0
    ball[i].rotype = 2
    ball[i].x = rnd(7,10)
    ball[i].y = rnd(-4,4)
    ball[i].z = 0
    ball[i].speed = rnd(3,5)/100
next

'background
back = []
back.sea = loadimage("plane/background.png")
back.x = 0 ; back.y = 0

'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) 
   
    redraw
    wait 1
until keydown(KEY_RETURN,true)

'reset to initial value
plane.rotate = 30
plane.rotype = 1
plane.x = -5
plane.y = 0
plane.z = 0
info.message =""


'----------------------------
' 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
   
    'background image
    draw image back.sea,back.x,back.y
    draw image back.sea,back.x + width(primary),back.y
    if back.x <= -width(primary) then
        back.x = 0
    else   
        back.x = back.x - 1.3
    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)

'background image of stage 2
back.island = loadimage("plane/island.png")
back.scale = 1.2

'info
info.score = 0
info.status = ""
info.lifes = 3
info.shot = ""

'translate
translate = []
translate.x = 0

'jet
jet = []
jet.cockpit = loadimage("plane/cockpit.png")
jet.yoke = loadimage("plane/yoke.png")
jet.angle = 0
jet.position =""

'plane
plane.x1 = rnd(-3,3)
plane.x2 = rnd(-3,3)
plane.x3 = rnd(-3,3)
plane.y1 = rnd(-2,0)
plane.y2 = rnd(-2,0)
plane.y3 = rnd(-2,0)
plane.z1 = rnd(10,30)
plane.z2 = rnd(10,30)
plane.z3 = rnd(10,30)
plane.rotype = 2
plane.rotate = 90
plane.position1 =""
plane.position2 =""
plane.position3 =""

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 
                             
    'background animation
    back.scale = back.scale + 0.002      
           
    '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)


Attached Files
.zip   devil triangle_v2.zip (Size: 1.5 MB / Downloads: 8)
.zip   devil_triangle_v3.zip (Size: 1.5 MB / Downloads: 3)
Reply


Messages In This Thread
Devil's Triangle (The Game) - by 1micha.elok - 05-10-2024, 09:05 AM
RE: Devil's Triangle (The Game) - by 1micha.elok - 05-15-2024, 10:51 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)