Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
S3D : the devil's triangle
#1
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)
Reply


Messages In This Thread
S3D : the devil's triangle - by 1micha.elok - 05-05-2024, 02:12 PM
RE: S3D : the devil's triangle - by Marcus - 05-05-2024, 03:01 PM
RE: S3D : the devil's triangle - by 1micha.elok - 05-06-2024, 01:34 AM
RE: S3D : the devil's triangle - by johnno56 - 05-06-2024, 07:56 AM
RE: S3D : the devil's triangle - by 1micha.elok - 05-06-2024, 08:45 AM
RE: S3D : the devil's triangle - by Marcus - 05-06-2024, 02:18 PM
RE: S3D : the devil's triangle - by johnno56 - 05-06-2024, 08:09 PM
RE: S3D : the devil's triangle - by 1micha.elok - 05-07-2024, 07:44 AM
RE: S3D : the devil's triangle - by Marcus - 05-07-2024, 07:19 PM
RE: S3D : the devil's triangle - by 1micha.elok - 05-08-2024, 07:26 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)