NaaLaa
Ask help to fix errors (game with wolf3d) - Printable Version

+- NaaLaa (https://www.naalaa.com/forum)
+-- Forum: NaaLaa (https://www.naalaa.com/forum/forum-1.html)
+--- Forum: NaaLaa 7 Questions (https://www.naalaa.com/forum/forum-3.html)
+--- Thread: Ask help to fix errors (game with wolf3d) (/thread-193.html)



Ask help to fix errors (game with wolf3d) - 1micha.elok - 02-05-2025

Hi, Marcus

You may reply me on weekend when you are not at work. It's not urgent  Big Grin

I am making an animation of a night driving with the wolf3d library.

           
click the images to zoom in

Could you please help me :
 - I don't know how to fixed some bugs
   1. the car is not turned smoothly on turn#4 and turn#3
   2. the zombie animation is overlapped
 - I don't know how to put the sky image as a background ( not as a tileset)


Code:
'====================================================
'
' ......
'
' Acknowlegements :
' -Haunted Night by Hot Dope
'  https://pixabay.com/music/search/mood/scary/
' -Zombie
'  https://opengameart.org/content/zombie-rpg-sprites
'====================================================

'----------------
' INITIALIZATION
'----------------
'#win32
set window "The Shadow", 1000,500,false
set redraw off; set mouse off

include "wolf3d.n7"
w3d = Wolf3D()
w3d.SetView(0, 0, width(primary), height(primary), rad(72))

' Player.
vPlayerAngle = 0
vPlayerX = 0
vPlayerZ = 0

' Load map.
flags = w3d.LoadN6Map("assets/map.txt")

' Player.
vPlayerX = flags[0].x + 0.5
vPlayerZ = flags[0].z + 0.5
vPlayerAngle = flags[0].angle

' Zombie
zombie = loadimage("assets/zombie7.png",3,4)
vCrossFrameCounter = 0
vCrossFrame = 0

' Sky
sky = loadimage("assets/sky.jpg")

'initial value
start = true
haunted = loadmusic("assets/haunted night.wav")
play music haunted,1

'---------------
' MAIN PROGRAM
'---------------
do
    'it's a bug. the sky is not displayed
    draw image sky,0,0

    'start moving
    if vPlayerZ = 13.5 and vPlayerX < 19 then
        vPlayerX = min(vPlayerX + 0.5/10,18.5)

        'turn #4   
        vPlayerAngle = 0 'it's a bug. it should turn smoothly

    endif

    'turn #1   
    if vPlayerX = 18.5 then vPlayerAngle = max(vPlayerAngle - 2.0,-90) 'turn smoothly
    if vPlayerX = 18.5 and vPlayerZ > 2.5 then vPlayerZ = max(vPlayerZ - 0.5/10,2.5)

    'turn #2
    if vPlayerZ = 2.5 then vPlayerAngle = max(vPlayerAngle - 2.0,-180) 'turn smoothly
    if vPlayerZ = 2.5 then vPlayerX = max(vPlayerX - 0.5/10,1.5)

    'turn #3
    if vPlayerX = 1.5 then vPlayerAngle = -270 'it's a bug. it should turn smoothly  
    if vPlayerX = 1.5 then vPlayerZ = min(vPlayerZ + 0.5/10,13.5)
   
    ' zombie, it'a bug, the zombie animation is overlapped
    if vCrossFrameCounter = 0
        vCrossFrame = (vCrossFrame + 1)%12
        dst = w3d.n6.imgDefs[7].img 
        set image dst
        draw image zombie, 0, 0, vCrossFrame
        set image primary
    endif
    vCrossFrameCounter = (vCrossFrameCounter + 1)%5
       
    'render
    w3d.Render(vPlayerX, vPlayerZ, rad(vPlayerAngle))
   
    'info box
    set color 255,255,255
    set caret 10,10
    wln "x = "+vPlayerX
    wln "z = "+vPlayerZ
    wln "a = "+vPlayerAngle

    redraw
    fwait 60
   
    'pause
    if start then
        wln "Press SPACE BAR to continue"
        redraw
        do;wait 1; until keydown(KEY_SPACE,true)
        start = false
    endif
   
until keydown(KEY_ESCAPE)

free music haunted