Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ask help to fix errors (game with wolf3d)
#1
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


Attached Files
.zip   the shadow.zip (Size: 2.14 MB / Downloads: 5)
Reply
#2
I'll have a closer look at the problems this weekend, but I'll comment on one of them now.

It's not possible to draw a background image, because the library (the part written in C) clears the screen when it renders its stuff. I can release a fix that doesn't clear the screen, or I can add a function to set a background image? I can render the image on the "inside of a cylinder" to make it look a bit more 3d (the n6 gloom library did this).
Reply
#3
One way to fix the sprite animation is to apply these changes. After loading the map:

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

' marcus: set colorkey of image used for sprites to black
set image colorkey w3d.n6.imgDefs[7].img, 0, 0, 0

In the game loop when updating the frame:

Code:
' zombie, it'a bug, the zombie animation was overlapped
    if vCrossFrameCounter = 0
        vCrossFrame = (vCrossFrame + 1)%12
        dst = w3d.n6.imgDefs[7].img
        set image dst
        ' marcus: clear with colorkey color
        set color 0, 0, 0
        cls
        set color 255, 255, 255
        draw image zombie, 0, 0, vCrossFrame
        set image primary
    endif
    vCrossFrameCounter = (vCrossFrameCounter + 1)%5
Reply
#4
Thank you for your time, my friend,
The zombie attack is just pretend
A lonely night driver speeds ahead,
While undead hands reach for his head

But don’t you worry, it’s just a game,
No rush at all, there's no real pain
Take your time, no need to race,
The zombies brought snacks—they'll save you a place

Big Grin
Reply
#5
While adding a "sky" feature to the wolf3d library I discovered a bug that causes a really bad crash (no error message) Sad I'll return with a new version of the library and n7 when I've located and fixed the problem. I also want to add some new commands for transformations when drawing polygons and ... maybe add support for loading mp3 files.
Reply
#6
I'm sorry, the new request made the program fall,
A sky for Wolf3D—it crashed it all
But hearing your plans, I’m truly impressed,
An enhanced new version? That sounds the best

MP3 support? Oh, what a delight,
Bringing new sounds to the game feels right.
When release day comes, I’ll give it a spin,
Excited to see the great work within
Reply
#7
(02-08-2025, 09:47 AM)1micha.elok Wrote: I'm sorry, the new request made the program fall,
A sky for Wolf3D—it crashed it all
But hearing your plans, I’m truly impressed,
An enhanced new version? That sounds the best

MP3 support? Oh, what a delight,
Bringing new sounds to the game feels right.
When release day comes, I’ll give it a spin,
Excited to see the great work within

Need to say that I haven't forgotten about this Smile  The bug I discovered is quite nasty and I'm still working on it.
Reply
#8
(02-15-2025, 08:21 AM)Marcus Wrote: ...
Need to say that I haven't forgotten about this Smile  The bug I discovered is quite nasty and I'm still working on it.

Don't worry, just take your time and enjoy your weekend ... It's a family time  


   
click the image to zoom-in
Oh no.... I have brought the nightmare of Wolfenstein into this night driving animation..... Big Grin

[update]
   
click the image to zoom-in
Compiled with N7 version 25.02.15

Thank you, the skytexture is perfect !
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)