Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HELP. The Mummy in s3d
#1
New S3d Library

           
click each image to zoom - in

The mummy is everywhere when I am facing North, South, West etc ... lol .....
Is there a way to put the mummy somewhere in certain coordinate (x,y,z) ?

Code:
'==================================================
' THE MAZE II
' Part 1. Sand Desert
' Part 2. to be
' Part 3. to be
'
' Control :
' SPACE     = move forward
' Mouse     = see around
'
' Reference :
' - s3d.n7 library, ex6_heightmap.n7 by Marcus
'
' Sand texture https://images.app.goo.gl/QwsHZq7hZVdyNXB76
' Mummy1 https://images.app.goo.gl/uiosCKdMHraZPfoC7
' Title https://images.app.goo.gl/AGLmRC8g9vQDg21Q6
'==================================================


'----------------
' INITIALIZATION
'----------------
include "data_maze2/heightmap_library.n7"
include "s3d.n7"; S3D_SetView(primary, rad(90), 0.1, 5)
set window "Maze 2 - Part 1.Sand Desert",400,200,false,3
set mouse off
set redraw off

'color definition
gray         = [128,128,128]
black        = [0,0,0]
white        = [255,255,255]
red          = [255,0,0]
green        = [0,255,0]
darkgreen    = [0,128,0,120]

' Heightmap and Ground
heightmapImg = loadimage("data_maze2/heightmap.png");hm = CreateHeightmap(heightmapImg, 8)
groundImg    = loadimage("data_maze2/ground.png")

' Camera
camX         = 32   ; camY          = 0 ; camZ      = 32 'position
camYaw       = 0    ; camPitch      = 0                  'rotation
camBobAngle  = 0    ; camBobEffect  = 0                  'when the user moves

' Mummy
mummy = []
mummy[1] = []
mummy[1].img = loadimage("data_maze2/mummy1.png")

' misc initial value
dt = 0.003
map = [] 'little map
map.x = width(primary)-100
map.z = height(primary)-80
map.w = width(heightmapImg)
map.h = height(heightmapImg)
map.r = map.w/2        'radius
map.cx = map.x+map.w/2 'center
map.cz = map.z+map.h/2 'center
map.a  = 0             'angle
pos = [] 'player's position
pos.x = 0
pos.y = 0
pos.z = 0

'-----------
' GAME LOOP
'-----------
while not keydown(KEY_ESCAPE, true)
    '----------
    ' control
    '----------
    ' Rotation
    mdx = mouserelx(); mdy = mouserely()
    camYaw = (camYaw + mdx*45*dt)%360 ; camPitch = min(max(camPitch - mdy*45*dt, -60), 60)
    set mouse width(primary)/2, height(primary)/2
   
    ' Movement
    dx = 0; dz = 0
    if keydown(KEY_SPACE)
        dx = dx + sin(rad(camYaw))
        dz = dz + cos(rad(camYaw))
    endif
    if dx or dz
        camBobAngle = camBobAngle + 500*dt          'when the user moves
        k = dt/sqr(dx*dx + dz*dz)
        camX = camX + k*dx                          'position X                 
        camZ = camZ + k*dz                          'position Z
        camBobEffect = min(camBobEffect + 4*dt, 1)  'when the user moves
    endif
    camY = hm.GetY(camX, camZ) - 0.5                'position Y
    pos.x = str(camX,0,1)
    pos.y = str(camY,0,1)
    pos.z = str(camZ,0,1)   
    map.a = 90-camYaw

    '------------
    ' rendering
    '------------
    ' Fill screen with the fog color.
    set color gray; cls

    ' Rendering Process
    S3D_Clear()
    S3D_SetSorting(S3D_BACK_TO_FRONT)
    S3D_SetDepthBuffer(S3D_Z_BUFFER_WRITE)
    S3D_RotateX(rad(-camPitch))
    S3D_RotateY(rad(-camYaw))
    S3D_Translate(-camX, -camY + 0.04*camBobEffect*sin(rad(camBobAngle)), -camZ)
    S3D_Texture(groundImg)
    S3D_Mesh(hm.mesh, 0)
    S3D_Render()
    S3D_RenderFog(gray[0],gray[1],gray[2],false)
       
    ' Just simple draw image
    set color white
    draw image mummy[1].img, 20,20               
       
    '------------
    ' navigation
    '------------
    set color black
        set caret 0,0; wln "Angle "+camYaw 'camYaw = 0 south, 90 east, 180 north, 270 west
        wln "Position "+pos.x+","+pos.y+","+pos.z
    set color darkgreen ; draw ellipse map.cx,map.cz,map.r,map.r,true
    set color green     
        draw ellipse map.cx,map.cz,map.r,map.r
        draw line    map.cx,map.cz,map.cx+map.r*cos(rad(map.a)),map.cz+map.r*sin(rad(map.a))
    set color red       ; draw ellipse (map.x+int(pos.x)),(map.z+int(pos.z)),2,2,true
    set color white     ; draw ellipse (map.x+int(pos.x)),(map.z+int(pos.z)),2,2
        set caret map.cx-18, map.z-13; wln "North" 
        set caret map.cx-18, map.z+map.h; wln "South"
        set caret map.x-35, map.cz-5; wln "West"
        set caret map.x+map.w+5, map.cz-5; wln "East"
   
    redraw
    wait 1
wend


Attached Files
.zip   maze2.zip (Size: 93.07 KB / Downloads: 5)
Reply


Messages In This Thread
HELP. The Mummy in s3d - by 1micha.elok - 04-18-2024, 12:52 PM
RE: HELP. The Mummy in s3d - by Marcus - 04-18-2024, 06:38 PM
RE: HELP. The Mummy in s3d - by johnno56 - 04-18-2024, 07:54 PM
RE: HELP. The Mummy in s3d - by 1micha.elok - 04-19-2024, 02:39 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)