Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 37
» Latest member: Ludwig
» Forum threads: 203
» Forum posts: 1,542

Full Statistics

Online Users
There are currently 93 online users.
» 0 Member(s) | 91 Guest(s)
Bing, Google

Latest Threads
Raylib and SmallBASIC....
Forum: Programming
Last Post: aurel
3 hours ago
» Replies: 1
» Views: 17
A diligent BASIC dialect(...
Forum: Programming
Last Post: luwal
Yesterday, 11:05 PM
» Replies: 2
» Views: 59
RW3
Forum: NaaLaa 7 Code
Last Post: 1micha.elok
Yesterday, 05:21 AM
» Replies: 6
» Views: 604
It's that time of year ag...
Forum: Everything else
Last Post: 1micha.elok
Yesterday, 05:09 AM
» Replies: 1
» Views: 46
Why all 80's Computers ha...
Forum: Everything else
Last Post: johnno56
05-03-2025, 02:08 PM
» Replies: 3
» Views: 105
The most used BASIC diale...
Forum: Programming
Last Post: johnno56
05-02-2025, 01:01 AM
» Replies: 13
» Views: 504
Most used game engines on...
Forum: Everything else
Last Post: johnno56
05-01-2025, 04:55 AM
» Replies: 1
» Views: 68
Suggestion: other classic...
Forum: Suggestions
Last Post: luwal
04-29-2025, 02:05 AM
» Replies: 2
» Views: 168
Suggestion: an example fo...
Forum: Suggestions
Last Post: luwal
04-27-2025, 06:16 PM
» Replies: 3
» Views: 185
BASIC replicator!
Forum: Everything else
Last Post: luwal
04-26-2025, 03:49 AM
» Replies: 2
» Views: 224

 
  The Stargate
Posted by: 1micha.elok - 06-07-2024, 11:38 AM - Forum: NaaLaa 7 Code - Replies (1)

 THE STARGATE
 Don't sleep, your nightmare is coming ...

       
click each image to zoom in

 Tips
 - Each kind of weapons has certain number of power / bullet
 - Switch your weapon when it has no power / bullet anymore
 - Use gun or crossbow to shoot
 - Use trident or bare hands for close combat

 Control keys :
 - W,A,S,D    movement
 - Mouse      rotation
 - ESC        quit
 - 1,2,3,4,5  select weapon
 - left click  to shoot

Code:
'========================================================================================
' THE STARGATE
' Don't sleep, your nightmare is coming ...
'
' Tips
' - Each kind of weapons has certain number of power / bullet
' - Switch your weapon when it has no power / bullet anymore
' - Use gun or crossbow to shoot
' - Use trident or bare hands for close combat
'
' Control keys :
' - W,A,S,D     movement
' - Mouse       rotation
' - ESC         quit
' - 1,2,3,4,5   select weapon
' - left click  to shoot
'
' Acknowledgement :
' - Marcus, enginea library, https://naalaa.com/forum/thread-124-post-929.html
' - Game assets
'   *Building Pixel by LandEnd Studios https://isaquerr.itch.io/building-pixel
'   *Free 3D Fps-Shooter Models | TurboSquid https://images.app.goo.gl/NQtoZhALCWDoYFPp6
'   *Stealth Battle background music by Mark, meak363 from Pixabay.com
'   *Different kinds of weapons such as trident, hands, crossbow of The Spriting Dark
'    Carnival https://www.altarofstone.com/forums/viewtopic.php?t=42
'   *Man Silhouette https://pixabay.com/vectors/man-silhouette-male-people-4329249/
'   *Monster https://images.app.goo.gl/6HiZncjYoCaJ7zSr9
'========================================================================================


'----------------
' INITIALIZATION
'----------------
#win32
include "myassets/enginea.n7"
include "myassets/disclaimer.n7"
set window "stargate",1000,500,false
set redraw off

'constant
constant ENEMY_ID         = 6

'color definition
visible white        = [255,255,255]
visible black        = [0,0,0]
visible green        = [0,255,0,150]
visible darkgreen    = [0,50,0]
visible red          = [255,0,0]
visible gray         = [0,0,0,150]

'set stage (view, fog, player, camera)
EA_SetView(primary, rad(65), 0.1,6)
EA_SetFog(EA_NORMAL, white[0],white[1],white[2])

'load game assets (font, music, weapon, map, player, enemy)
visible font20 = createfont("Courier New", 20, false, false, false, false)
visible font40 = createfont("Courier New", 40, false, false, false, false)
visible music_ = loadmusic("myassets/battle3.wav")
play music music_,1

visible weapon  = []
visible w       = 1
weapon[1]       = loadimage("myassets/shooter.png")
weapon[2]       = loadimage("myassets/crossbow.png")
weapon[3]       = loadimage("myassets/triple.png")
weapon[4]       = loadimage("myassets/hands.png")   

visible info    = []
info.gun        = 2
info.crossbow   = 2
info.trident    = 2
info.barehands  = 2
info.lifes      = 100

visible abort       = loadimage("myassets/abort.png")
visible failed      = loadimage("myassets/failed.png")   

visible enemy1      = loadimage("myassets/man.png",4,1)
visible enemy2      = loadimage("myassets/monster.png",4,1) 
visible enemyBullet = loadimage("myassets/enemy_bullet.png",4,1)

visible playerBullet = []
playerBullet[1] = loadimage("myassets/shooter_bullet.png", 4, 1)
playerBullet[2] = loadimage("myassets/crossbow_arrow.png", 4, 1)

flags = EA_LoadMap("myassets/map.json")
visible player = unset
foreach f in flags
    select f.flag
        case "player"
            player = CreatePlayer(f.x, f.floorY, f.z)
            EA_AddObject(player)
            EA_SetCamera(player)
        case "monster"
            o = CreateEnemy(f.x, f.ceilingY, f.z)
            EA_AddObject(o)
    endsel
next


Disclaimer()
'-------------------------
' MAIN (update,draw,run)
'-------------------------   
EA_SetUpdateAction(Update)
EA_SetDrawAction(Draw)
EA_Run()
'------------------------


'-----------
' FUNCTIONS
'-----------
function Update(dt)
    if keydown(KEY_ESCAPE,true) then
        EA_SetDrawAction(Message(abort))
        EA_Stop()
    endif
    if keydown(KEY_M) then stop music music_
endfunc

function Draw()
    set color white
    if keydown(KEY_1) then w=1 'gun shooter
    if keydown(KEY_2) then w=2 'crossbow
    if keydown(KEY_3) then w=3 'trident       close combat
    if keydown(KEY_4) then w=4 'bare hands    close combat
    draw image weapon[w],
      (width(primary)-width(weapon[w]))/2 - 23 + cos(player.bobAngle*0.5)*player.bobEffect*8,
      height(primary)-height(weapon[w])+15 + sin(player.bobAngle)*player.bobEffect*6,
      0   
   
    ' info box
    set color gray
    draw rect 20,20,200,200,1   
    set color white
    set caret 40,40
    wln "INFO BOX"
    wln "-------------------"
    wln "Weapon Power"
    wln "1.Gun        : " + info.gun
    wln "2.Crossbow   : " + info.crossbow
    wln "3.Trident    : " + info.trident
    wln "4.Bare hands : " + info.barehands
    wln
    wln "Lifes        : " + info.lifes
    wln "-------------------"
               
    ' Crosshair.
    if w=1 then
        set color darkgreen
        cx = width(primary)/2+ cos(player.bobAngle*0.5)*player.bobEffect*8
        cy = height(primary)/2+10+ sin(player.bobAngle)*player.bobEffect*6
        draw ellipse cx,cy, 20, 20, false
        draw line cx-40, cy, cx+40, cy
        draw line cx,cy-40, cx, cy+40
    endif
   
    'Player's angle and coordinates
    angle = round(deg(player.Yaw())%360)'0=south, 90=west, 180= north, 270=east
    x = round(player.X())
    y = abs(round(player.Y()))
    z = round(player.Z())

    set font font20

    'Compass
    set color white 
    set caret 50,320; wln "Compass"
    set color green
    draw ellipse 80,410,70,70,1
    set color darkgreen
    draw ellipse 80,410,70,70
    draw ellipse 80,410,60,60
    draw ellipse 80,410,20,20
    set color white
    draw ellipse 80,410,10,10,1
    needle = [
    80-10*cos(rad(angle+180)),410-10*sin(rad(angle+180)),
    80+70*cos(rad(angle+90)),410+70*sin(rad(angle+90)),
    80+10*cos(rad(angle-180)),410+10*sin(rad(angle-180))
    ]
    draw poly needle,1
    draw line 80,410,80+70*cos(rad(angle+90)),410+70*sin(rad(angle+90))
       
    'Map
    size = 30
    w_map = 7
    h_map = 5
    x_rect = width(primary)-w_map*size-40
    z_rect = 340   
    set color green 'frame 
    draw rect x_rect,z_rect,(w_map+1)*size,h_map*size,1
    set color darkgreen 'grid
    for i = 0 to w_map+1 draw line x_rect+i*size,z_rect,x_rect+i*size,z_rect+h_map*size 'vertical
    for i = 0 to h_map  draw line x_rect,z_rect+i*size,x_rect+(w_map+1)*size,z_rect+i*size 'horiontal
   
    'Player's position on the map
    posx = x_rect+(w_map-x+2)*size
    posz = z_rect+(z-2)*size   
    set color white
    draw rect posx,posz,size,size,1
   
    'Map title
    set color white
    set caret x_rect,z_rect-20; wln "Map "+x+","+y+","+z
       
    set font 0 'default
endfunc

function CreatePlayer(x, y, z)
    player = EA_FpsPlayer()
    player.SetPos(x, y, z)
    player.SetMouseSens(0.3)

    player.bobAngle = 0
    player.bobEffect = 0
    player.stimer = 0
   
    player.SetYaw(rad(180)) '0=south, 90=west, 180= north, 270=east
    player.SetJumpKey(unset) 'disable jump (SPACE BAR)
   
    player.Update = function(dt)
         .bobAngle = (.bobAngle + 8*dt)%(PI*4)
         .bobEffect = min(.bobEffect + 2.0*dt, 1)
        .stimer = max(.stimer - dt, 0)
        if mousebutton(0, true) and .stimer = 0 and (w=1 or w=2) then
        'left mouse, gun shooter or crossbow
            .stimer = 0.5
           
            if w=1 and info.gun>0 then       
                EA_AddObject(CreatePlayerBullet(
                    playerBullet[w],
                    .X() + .DX()*0.2, .Y() - 0.3 + .DY()*0.2, .Z() + .DZ()*0.2,
                    .DX()*4, .DY()*4, .DZ()*4))
               
                info.gun = info.gun - 1
            endif
           
            if w=2 and info.crossbow>0 then
                EA_AddObject(CreatePlayerBullet(
                    playerBullet[w],
                    .X() + .DX()*0.2, .Y() - 0.3 + .DY()*0.2, .Z() + .DZ()*0.2,
                    .DX()*4, .DY()*4, .DZ()*4))
               
                info.crossbow = info.crossbow - 1           
            endif
        endif         
    endfunc
   
    return player
endfunc

function CreatePlayerBullet(img, x, y, z, dx, dy, dz)
    b = EA_Object()
    b.SetPos(x, y, z)
    b.SetSprite(img, 0, false)
    b.SetHeight(height(img)/64)
    b.SetRadius(0.5*width(img)/64)
    b.dx = dx
    b.dy = dy
    b.dz = dz
    b.numCels = cels(img)
    b.cel = 0
    b.Update = function(dt)
        if .numCels > 1
            .cel = (.cel + dt*30)%.numCels
            .SetCel(int(.cel))
        endif
        res = .Move(.dx*dt, .dy*dt, .dz*dt, 0)
        if res.any
            EA_RemoveObject(this)
        else
            objs = .SectorObjects()
            if objs and sizeof(objs)
                for i = 0 to sizeof(objs) - 1
                    if objs[i].id = ENEMY_ID
                        if .CollidesWith(objs[i])
                            objs[i].Hit(.dx, .dz)
                            EA_RemoveObject(this)       'remove bullet
                            EA_RemoveObject(objs[i])    'remove enemy
                            break
                        endif
                    endif
                next
            endif
        endif
    endfunc

    return b
endfunc

function CreateEnemy(x, y, z)
    enemy = EA_Object()
    enemy.id = ENEMY_ID
   
    enemy.state = 0 ' State 0 = falling, state 1 = on the gound.
    enemy.SetSprite(enemy1, 0, true)
    enemy.SetHeight(height(enemy1)/400)
    enemy.SetRadius(0.5*width(enemy1)/400)
    enemy.dy = 0.01 + rnd()/20 'vertical random speed
   
    enemy.SetPos(x, y, z)
    enemy.SetYaw(rad(rnd(360)))
    enemy.cel = 0
    enemy.push = 0
    enemy.pushDX = 0
    enemy.pushDZ = 0
   
    enemy.Update = function(dt)
        .stimer = max(.stimer - dt, 0)
        if .stimer = 0 and .state=1
            .stimer = 0.5
            EA_AddObject(CreateEnemyBullet(
                enemyBullet,
                .X() + .DX()*0.2, .Y() - 0.3 + .DY()*0.2, .Z() + .DZ()*0.2,
                .DX()*4, .DY()*4, .DZ()*4))
        endif       
   
        .cel = (.cel + dt*4)%4              'animation
        .SetCel(int(.cel))                  'animation   
        if .state = 0                       'Falling from the sky (... ceiling).
            res = .Move(0, .dy*dt, 0, 0)    'only move vertically
            if res.g                        'ground collision
               .state = 1                   'change state to 1
               .dy = 1                      'set gravity to 1
               .SetSprite(enemy2, 0, true)
            endif
        else
            res = .Move(.DX()*0.75*dt, .dy, .DZ()*0.75*dt, 0)
            if res.w 'wall
                .SetYaw(rad(deg(atan2(res.dx, res.dz)) - 90 + rnd()*180))
            endif
            .push = max(.push - 1.5*dt, 0)
        endif
       
        'collision enemy and player (close combat)
        if .CollidesWith(player) and (w=3 or w=4) then
        'close combat trident or barehands
            if info.trident > 0 and w=3 then
                EA_RemoveObject(this)
                info.trident = info.trident - 1   
            endif
           
            if info.barehands > 0 and w=4 then
                EA_RemoveObject(this)
                info.barehands = info.barehands - 1
            endif     
        endif 
       
        'collision enemy and player (not close combat)
        if .CollidesWith(player) and (w=1 or w=2) then 'not a close combat, only gun or crossbow
            info.lifes = info.lifes - 1
            if info.lifes<=0 then Message(failed)
            set color red
            draw rect 0,0,width(primary),height(primary),1
            redraw
            fwait 60
        endif   
       
    endfunc
   
    enemy.Hit = function(dx, dz)
        .pushDX = .push*.pushDX + dx
        .pushDZ = .push*.pushDZ + dz
        .push = 1
        .htimer = 0.15
    endfunc
   
    return enemy
endfunc

function CreateEnemyBullet(img, x, y, z, dx, dy, dz)
    b = EA_Object()
    b.SetPos(x, y, z)
    b.SetSprite(img, 0, false)
    b.SetHeight(height(img)/64)
    b.SetRadius(0.5*width(img)/64)
    b.dx = dx
    b.dy = dy
    b.dz = dz
    b.numCels = cels(img)
    b.cel = 0
    b.Update = function(dt)
        if .numCels > 1
            .cel = (.cel + dt*30)%.numCels
            .SetCel(int(.cel))
        endif
        res = .Move(.dx*dt, .dy*dt, .dz*dt, 0)
        if res.any
            EA_RemoveObject(this)
        else
            'collision detection enemy bullet and player
            if .CollidesWith(player)
                info.lifes = info.lifes - 1
                if info.lifes<=0 then Message(failed)
                set color red
                draw rect 0,0,width(primary),height(primary),1
                redraw
                fwait 60
            endif
        endif
    endfunc

    return b
endfunc

function Message(img)
    set color white
    draw image img,(width(primary)-width(img))/2,(height(primary)-height(img))/2
    set font font40
    set caret width(primary)/2,height(primary)-50
    center "Press ESC to continue"
    redraw
    do; wait 1 ;until keydown(KEY_ESCAPE,true)
    set font 0 'default
    Closing_Credits()
    end
endfunc



Attached Files
.zip   stargate_final.zip (Size: 3.76 MB / Downloads: 7)
Print this item

  3D Modelling - Blender
Posted by: johnno56 - 06-05-2024, 06:37 AM - Forum: Everything else - Replies (4)

Marcus,

Many years ago, and I may have mentioned this before, I attempted to use Blender to add objects to Cube2 (sauerbratten) primarily to see if I could and to determine how much work was involved. I had no idea about making models - and still don't - so I used a 'tutorial' to make a 3D wooden crate and a 3D vase.

Initially, the overall "look" of Blender was, for want of a better word, intimidating... Thankfully I had the tutorials to work through. I think it took about half an hour to create each model. Repetition would obviously improve efficiency, but both objects were created successfully... mind you, the final 'size' of the models, looked a little out of place... I think they were too big...

Back then I wasn't interested in 'animations'... ha... I had enough trouble getting my head around static objects... lol

I went online to check 3D modelling software... Yikes... Most either had some huge purchase costs or subscription based plans. There were one or two "free" packages but were quite limited in what they could do...

Found, downloaded and installed the latest version of Blender... Started it up... Almost fell off the chair... I thought the really old version of Blender was intimidating!! I am not sure I have enough years left in me to learn everything... For free and open source software it sure has pretty much all the "bells and whistles"... Really impressive... but scary!

   

Time to checkout tutorials again... *gulp*

Print this item

  return movement
Posted by: aliensoldier - 05-20-2024, 02:47 PM - Forum: NaaLaa 7 Questions - Replies (9)



In the first level there are those mechanical birds that move from left to right but at any moment they launch themselves towards the player and then return to their initial position. How can you make them return to their initial position with that motion?

Print this item

  Happy Birthday
Posted by: 1micha.elok - 05-19-2024, 04:57 AM - Forum: Everything else - Replies (4)

Happy Birthday, Marcus
May happiness be with you.

Print this item

  "A Game Jam is Coming Up"
Posted by: luwal - 05-18-2024, 03:49 PM - Forum: Programming - Replies (28)

Ha........I read an introduction post about a game jam in another forum. Maybe some members of our user community will be interested in creating a creative game for the jam. Big Grin  
https://forum.thegamecreators.com/thread/229610

Print this item

  Scrolling
Posted by: johnno56 - 05-15-2024, 07:37 AM - Forum: NaaLaa 7 Questions - Replies (3)

If one were to say, create a side scrolling Mario-type game that has a level much wider than the desktop, would there be such an example or tutorial on how to use the tilemap library to control the camera and scrolling? Just in case one were to consider such a project...

All I have is the Tilemap Editor PDF file as reference... No rush...

Print this item

  Enchanted Forest
Posted by: 1micha.elok - 05-14-2024, 04:16 AM - Forum: NaaLaa 7 Code - Replies (8)

ENCHANTED FOREST
Explore the enchanted forest with your own character, Barbarian or Knight.
And rearrange the forest as you like.

UPDATE Enchanted Forest v3
           
click each image to zoom in
1. Introduction Scene
2. Reset your character position
3. Closing Credits Scene

Code:
'==========================================================================
'THE ENCHANTED FOREST v.3
'Explore the enchanted forest with your own character, Barbarian or Knight.
'And rearrange the forest as you like.
'
'Need to be improved :
'- Position of the character relative to the objects
'- Collision detection between the character and the objects
'- Boundary of the screen
'
'Acknowledgment
's3d library - by Marcus
'KayKit - Adventurers by Kay Lousberg
'   https://kaylousberg.itch.io/kaykit-adventurers?download
'Trees Asset Pack by Aumarka
'   https://mark-auman.itch.io/low-poly-trees-asset-pack
'==========================================================================


'----------------
' INITIALIZATION
'----------------
'#win32
include "s3d.n7"; S3D_SetView(primary, rad(45), 0.1, 50)
include "data/s3d_addon.n7"

set window "The Enchanted Forest",1000,600,false
set redraw off
randomize clock()

'color definition
white   = [255,255,255]
black   = [40,42,54]
gray    = [200,200,200]
red     = [255,0,0]

'characters
character = []
character[0]        = []
character[1]        = []
character[0].model  = S3D_LoadMesh("data/Barbarian.obj", 0.7,-0.7,0.7, false)
character[1].model  = S3D_LoadMesh("data/Knight.obj", 0.7,-0.7,0.7, false)
character[0].name   = "Barbarian"
character[1].name   = "Knight"
character.rotate    = 0
character.rotype    = 2
character.x         = 3.8
character.y         = 2.8
character.z         = 7

'objects
object = []
object.number = 5
object.rotate = 0
object.rotype = 2
for j = 1 to object.number
    object[j] = []
    object[j].model = S3D_LoadMesh("data/Tree_Bare.obj", 0.01,-0.01,0.01, false)
    object[j].x = rnd(-5,2) ; object[j].y = rnd(1,2) ; object[j].z = rnd(5,15)
next


'------------
' 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 for eductional purpose only. "
wln "It is as 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 
wln "All trademarks and game assets are the property of their respective owners." 
wln "While every effort is made to acknowledge their works,"
wln "some of the game assets used in in this tiny game may not have"
wln "clear name of the artists/author/creator/developer to be referred with."
wln "It may not include all relevant facts or the most up-to-date information."
wln       
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)


'--------------
' INTRODUCTION
'--------------
i = 0
character.x         = 0
character.y         = 0
character.z         = 0
character.rotate    = 200
do     
    set color black; cls; set color white; S3D_Clear()
   
    'choose your character
    if keydown(KEY_C,true) then
        i = (i+1)%2
    endif

    'character.rotate -90=West, 90=East, 0=North, 180=South
    if keydown(KEY_LEFT) then
        character.rotate = (character.rotate+10)%360
    elseif keydown(KEY_RIGHT) then
        character.rotate = (character.rotate-10)%360
    endif
   
    S3D_Translate(0, 1, 3)
    S3D_Draw(character.x,character.y,character.z,character.rotype,character.rotate,character[i].model)
   
    'information
    set color white; set caret 10,10
    wln "===================="
    wln "INTRODUCTION"
    wln character[i].name
    wln "===================="
    wln
    wln "Instructions :"
    wln "LEFT, RIGHT  to rotate your character"   
    wln "C            to change your character"
    wln "ESCAPE       to quit this introduction"

    redraw
    fwait 10
until keydown(KEY_ESCAPE,true)


'-----------
' MAIN LOOP
'-----------
i = 0; j=1
character.x         = 2
character.y         = 2
character.z         = 5
character.rotate    = 210
do     
    set color black; cls; set color white; S3D_Clear()
   
    'choose your character
    if keydown(KEY_C,true) then
        i = (i+1)%2       
    endif
   
    'randomize objects
    if keydown(KEY_R,true) then
        for j = 1 to object.number
            object[j] = []
            object[j].model = S3D_LoadMesh("data/Tree_Bare.obj", 0.01,-0.01,0.01, false)
            object[j].x = rnd(-5,2) ; object[j].y = rnd(0,2)+1 ; object[j].z = rnd(5,15)
        next
    endif
   
    'show up your character if he is out of screen
    if keydown(KEY_U,true) then
        character.x         = 2
        character.y         = 2
        character.z         = 5
        character.rotate    = 210   
    endif
   
    'character.rotate -90=West, 90=East, 0=North, 180=South
    if keydown(KEY_LEFT,true) then
        character.rotate = (character.rotate+30)%360
    elseif keydown(KEY_RIGHT,true) then
        character.rotate = (character.rotate-30)%360
    endif
   
    if keydown(KEY_UP,true) then
        if character.rotate = 0 then
            character.z = character.z + 0.1
        elseif character.rotate = 90 then
            character.x = character.x + 0.1
        elseif character.rotate = 180 then
            character.z = character.z - 0.1
        elseif character.rotate = 270 then
            character.x = character.x - 0.1
        elseif character.rotate > 0 and character.rotate < 90 then
            character.x = character.x + 1.2*cos(rad(character.rotate))
            character.z = character.z + 1.2*sin(rad(character.rotate))
        elseif character.rotate > 90 and character.rotate < 180 then
            character.x = character.x - 1.2*cos(rad(character.rotate))
            character.z = character.z - 1.2*sin(rad(character.rotate))
        elseif character.rotate > 180 and character.rotate < 270 then
            character.x = character.x + 1.2*cos(rad(character.rotate))
            character.z = character.z + 1.2*sin(rad(character.rotate))    
        elseif character.rotate > 270 and character.rotate < 360 then
            character.x = character.x - 1.2*cos(rad(character.rotate))
            character.z = character.z - 1.2*sin(rad(character.rotate))              
        endif
       
        'boundary
        if character.z > 20 then character.z = character.z - 0.5
        if character.z < 2.8 then character.z = character.z + 0.5
    endif

    'object animation
    object.rotate = object.rotate + 0.2
     
    'lines
    set color gray ;  cx = width(primary)/2 ; cy = height(primary)/2
    for a = 1 to 50 step 0.15  draw line 0,cy+pow(a,7),cx*2,cy+pow(a,7)
    for b = -1000 to cx*2+1000 step 230  draw line cx,cy/2,b,cy*2
    set color black; draw rect 0,0,cx*2,cy+2,1
     
    'Draw Objects and Character
    for j = 1 to object.number 
        S3D_Draw(object[j].x,object[j].y,object[j].z,object.rotype,object.rotate,object[j].model)
        set color white
        set caret width(primary)-100,30; wln "Objects";wln "Coordinates"
        set caret width(primary)-100,60+j*20
        wln j+":"+object[j].x+","+object[j].y+","+object[j].z
    next
    S3D_Draw(character.x,character.y,character.z,character.rotype,character.rotate,character[i].model)
       
    'information
    set color white; set caret 10,10
    wln "===================="
    wln "The Enchanted Forest"
    wln "===================="
    wln
    wln "Instructions :"
    wln "ESC          to quit"
    wln "R            to re-arrange objects"
    wln "LEFT, RIGHT  to rotate your character"
    wln "UP           to move forward"
    wln "C            to change your character"
    wln "U            to reset your position"
    wln  
    set caret width(primary)-300,30
    wln "You are a "+character[i].name
    wln
    wln "Your Coordinates"  
    wln int(character.x)+","+int(character.y)+","+int(character.z)
    wln
    wln "Compass "+character.rotate+ " degrees"
    x1 = width(primary)-240
    y1 = 190
    x2 = x1 + 50*cos(rad(270+character.rotate))
    y2 = y1 + 50*sin(rad(270+character.rotate))
    draw ellipse x1,y1,50,50
    draw line x1,y1,x2,y2    
      
    redraw
    wait 1
until keydown(KEY_ESCAPE,true)


'-----------------
' Closing Credits
'-----------------
words = []
words[1] = "CLOSING CREDITS"
words[2] = ""   
words[3] = ""
words[4] = "A special thanks to Marcus, the creator of Naalaa" 
words[5] = "for his dedication, support and encouragement"
words[6] = "in the making of this tiny game."
words[7] = ""
words[8] = "I really appreciate his stepping in"
words[9] = "to develop the fantastic s3d library"
words[10] = "I know he had to put in extra hours"
words[11] = "to catch up on his own work, so thank you very much."
words[12] = "Your expertise was vital for this tiny game."
words[13] = ""
words[14] = "Heartfelt thanks to all the talented artists"
words[15] = "who created the amazing 3D game assets"
words[16] = "I couldn't have made it without them"
words[17] = ""
words[18] = ""
words[19] = ""
words[20] = "s3d library - by Marcus"
words[21] = ""
words[22] = "KayKit - Adventurers by Kay Lousberg"
words[23] = "   https://kaylousberg.itch.io/kaykit-adventurers?download"
words[24] = ""
words[25] = "Trees Asset Pack by Aumarka"
words[26] = "   https://mark-auman.itch.io/low-poly-trees-asset-pack"                                                  

'text animation of the closing credits
for i = height(primary)-30 to 30
    set color black; cls; set color white
    set caret width(primary)/2,i
    for j = 1 to 26
        center words[j]
    next
    redraw
    fwait 40
next
do; wait 1; until keydown(KEY_RETURN,true)



Attached Files
.zip   Enchanted Forest.zip (Size: 460.22 KB / Downloads: 5)
.zip   Enchanted Forest_v3.zip (Size: 460.92 KB / Downloads: 4)
Print this item

  Devil's Triangle (The Game)
Posted by: 1micha.elok - 05-10-2024, 09:05 AM - Forum: NaaLaa 7 Code - Replies (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)
Print this item

  S3D : the devil's triangle
Posted by: 1micha.elok - 05-05-2024, 02:12 PM - Forum: NaaLaa 7 Questions - Replies (9)

The Devil's Triangle

           
click each image to zoom in

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]

'plane
plane = []
plane.model = S3D_LoadMesh("plane/Plane01.obj", 0.5,-0.5,0.5, false)
plane.rotate = 30
plane.x = -5 ; plane.y = 0 ; plane.z = 10

'pyramid
pyramid = []
pyramid.rotate = 0
pyramid.x = 20; pyramid.y = 6 ; pyramid.z = 10
pyramid.texture = loadimage("plane/fire.png")
pyramid.mesh =
S3D_BeginMesh()
    S3D_Begin(S3D_TRIANGLES) 'sides
        S3D_Push()
        for i = 0 to 3
            S3D_Vertex(0, -1, 0, 0.5, 0)
            S3D_Vertex(1, 1, -1, 1, 1)
            S3D_Vertex(-1, 1, -1, 0, 1)
            S3D_RotateY(rad(90))
        next
        S3D_Pop()
    S3D_End()
   
    S3D_Begin(S3D_QUADS) 'bottom
        S3D_Vertex(1, 1, -1, 1, 0)
        S3D_Vertex(1, 1, 1, 1, 1)
        S3D_Vertex(-1, 1, 1, 0, 1)
        S3D_Vertex(-1, 1, -1, 0, 0)
    S3D_End()
S3D_EndMesh()


'-----------
' MAIN LOOP
'-----------
while not keydown(KEY_ESCAPE, true)
    set color black; cls; S3D_Clear()

    'information
    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
        else
            plane.y = 4
        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
        else
            plane.y = -4
        endif
    endif
    S3D_Translate(plane.x, plane.y, plane.z)
    S3D_RotateX(rad(plane.rotate))
    S3D_Mesh(plane.model, 0)   

    'pyramid   
    pyramid.rotate = (pyramid.rotate + 30*0.03)%360
    if pyramid.x < - 5 then
        pyramid.x = 20
    else
        pyramid.x = pyramid.x - 0.01
    endif
    S3D_Push()
        S3D_Translate(pyramid.x, pyramid.y, pyramid.z)
        S3D_RotateX(rad(pyramid.rotate))
        S3D_RotateZ(rad(270))
        S3D_Texture(pyramid.texture)
        S3D_Scale(0.5,0.5,0.5)
        S3D_Mesh(pyramid.mesh, 0)
    S3D_Pop()       

    redraw
    wait 1
wend



Attached Files
.zip   devil_triangle.zip (Size: 44.79 KB / Downloads: 2)
Print this item

  Just for the Star Wars fans...
Posted by: johnno56 - 05-04-2024, 12:29 PM - Forum: Everything else - Replies (7)

May the forth be with you.

Happy will you be, yes...

Print this item