Author Topic: TD (the library and editor used for Robowack 2)  (Read 3303 times)

johnno56

  • Guest
Re: TD (the library and editor used for Robowack 2)
« Reply #15 on: December 02, 2014 »
Sorry guys, I do not mean to butt in, but have you investigated the problem as hardware? I've had a few 'glitchy' mice in my days (both analogue and digital) with similar effects. Even the 'type' of surface of your 'mouse pad' can have a similar effect. Maybe gfx drivers (if any other apps are effected...)

I only mention this because I do not experience any problems.

If you have already discounted the 'hardware' theory, then by all means, disregard this message and accept my apologies for wasting your time.

Cheers

J

X54321

  • Newbie
  • *
  • Posts: 38
  • I make games and cartoons. And stuff.
    • View Profile
    • Bitendo Software
Re: TD (the library and editor used for Robowack 2)
« Reply #16 on: December 02, 2014 »
While that may be the case, my mouse has played quite a lot of first person shooters, of all kinds and I've never had this problem.
Nevertheless, I tried the examples with the mouse-pad on my laptop. The problem was a little lesser, but it was still there.
Actually, like I said, example 5 and Robowack 2 work fine, despite using the same methods of mouse detection as the other ones.
-The Tophat Demon

johnno56

  • Guest
Re: TD (the library and editor used for Robowack 2)
« Reply #17 on: December 03, 2014 »
Does this problem exist on anyone else's machine? If not, might I suggest, the problem may be machine specific? Perhaps a fresh install of N6 and TD. That may solve any possible corrupted files in either N6 or TD. Thoughts?

J

Rick3137

  • Sr. Member
  • ****
  • Posts: 341
  • May the Force be with You
    • View Profile
    • Rick's Programs
Re: TD (the library and editor used for Robowack 2)
« Reply #18 on: December 03, 2014 »
Well, I recorded a video showing what exactly is happening.
https://www.youtube.com/watch?v=mCevHR1brok&feature=youtu.be
Again, it didn't happen in example 5 or example 1.

I looked at your video and it should not have a mouse cursor.
Look at line 63 and make sure you have: _glShowCursor false
Try moving line 63 to line 16.

 I use Windows7. Maybe your version is different?

Marcus

  • Administrator
  • Hero Member
  • *****
  • Posts: 542
    • View Profile
Re: TD (the library and editor used for Robowack 2)
« Reply #19 on: December 03, 2014 »
There's no point in posting the dll I compiled yesterday, becsuse it would only help if the problem had something to do wirh the keyboard.

Even if the problem is rare and machine dependant I want it fixed :)

What the extension does is to send mouse info to the naalaa runtime. Naalaa doesn't know that the coordinates don't come from its own window. The window you see is created by the extension. The normal naalas window is hidden. It's possible that, for some reason, this hidden window generates mouse events that mess things up on you system. I'll start with looking at that.
.\\\opz

Marcus

  • Administrator
  • Hero Member
  • *****
  • Posts: 542
    • View Profile
Re: TD (the library and editor used for Robowack 2)
« Reply #20 on: December 03, 2014 »
Could you perhaps try to pass false to the td initialization function? Then the naalas window won't be hidden, but maybe that also makes it behave differently (if it's even related to this).
.\\\opz

Marcus

  • Administrator
  • Hero Member
  • *****
  • Posts: 542
    • View Profile
Re: TD (the library and editor used for Robowack 2)
« Reply #21 on: December 03, 2014 »
I'm also thinking about workarounds. Does it become better if we don't hijack the mouse as frequently:

Code: [Select]
rem Example 2 - Load and walk through a TD map with mouse control.
rem
rem This is just about the same thing as the previous example but
rem using a map created with TD Editor and with the ability to look
rem up and down.

import "TD.lib"
import "Speed.lib"
import "Keycodes.lib"

rem Init TD library and open an OpenGL window, close NaaLaa window.
if not TD_Init("Example 3", 32, 32, 640, 480, 65.0, 0.1, 16.0, true) then end

rem Player properties.
rem Position.
playerX#
playerY#
playerZ#
rem Direction.
playerDirection#
playerPitch#
rem Walk effect.
playerBobAngle#

rem Load map created with RC Editor.
if not TD_LoadMap("maps/1.bin") then end

rem Use camera position saved in map as starting position.
playerX = TD_CamX()
playerY = TD_CamY()
playerZ = TD_CamZ()
rem Same with direction.
playerDirection = TD_CamYaw()

rem Set some spooky fog.
proc TD_SetFog 0, 32, 16, 2.0, 8.0

_glFullScreen

rem Hide mouse cursor and center its position.
_glShowCursor false
_glMoveCursor TD_GetWidth()/2, TD_GetHeight()/2
lastMouseX = mousex()
lastMouseY = mousey()


do
rem Call once every frame.
proc TD_Update

rem Move
dx#
dz#

rem Get mouse movement and re-center cursor.
mx = mousex()
my = mousey()
mouseDX = mx - lastMouseX
mouseDY = my - lastMouseY
if mx < 32 or mx > TD_GetWidth() - 32 or my < 32 or my > TD_GetHeight() - 32
mx = TD_GetWidth()/2
my = TD_GetHeight()/2
_glMoveCursor mx, my
endif
lastMouseX = mx
lastMouseY = my

if keydown(VK_UP)
dx = cos(playerDirection)*0.04
dz = sin(playerDirection)*0.04
playerBobAngle = playerBobAngle + 10.0
endif
if keydown(VK_DOWN)
dx = -cos(playerDirection)*0.04
dz = -sin(playerDirection)*0.04
playerBobAngle = playerBobAngle - 10.0
endif
if keydown(VK_LEFT)
dx = cos(playerDirection - 90.0)*0.04
dz = sin(playerDirection - 90.0)*0.04
endif
if keydown(VK_RIGHT)
dx = cos(playerDirection + 90.0)*0.04
dz = sin(playerDirection + 90.0)*0.04
endif
rem Use mouse movement for direction and pitch.
playerDirection = playerDirection + float(mouseDX)*0.5
playerPitch = max#(min#(playerPitch + float(mouseDY)*0.25, 60.0), -60.0)

rem Move with collision handling. playerX, playerY and playerZ.
proc TD_Move playerX, playerY, playerZ, dx, -0.1, dz, 0.25, 1.1, 0.2

rem Set camera position and orientation.
_TD_SetCamPosition playerX, playerY + 1.0 + sin(playerBobAngle)*0.05, playerZ
_TD_SetCamOrientation playerDirection, playerPitch, 0.0

rem Render and flush graphics to window.
_TD_Render
_TD_Flush

_SPD_HoldFrame 60
until TD_Running() = false or keydown(VK_ESC, true)

Or is the result okay if we limit the movement each frame, like:

Code: [Select]
mouseDX = min(max(mouseDX, -16), 16)
mouseDY = min(max(mouseDY, -16), 16)

Or will the player feel that there's a limitation? It really depends on what exactly is going on.

It looks as if the mouse cursor doesn't get re-centered properly every frame. Maybe you can store the new mouse coordinates after centering the mouse:

Code: [Select]
rem Example 2 - Load and walk through a TD map with mouse control.
rem
rem This is just about the same thing as the previous example but
rem using a map created with TD Editor and with the ability to look
rem up and down.

import "TD.lib"
import "Speed.lib"
import "Keycodes.lib"

rem Init TD library and open an OpenGL window, close NaaLaa window.
if not TD_Init("Example 3", 32, 32, 640, 480, 65.0, 0.1, 16.0, true) then end

rem Player properties.
rem Position.
playerX#
playerY#
playerZ#
rem Direction.
playerDirection#
playerPitch#
rem Walk effect.
playerBobAngle#

rem Load map created with RC Editor.
if not TD_LoadMap("maps/1.bin") then end

rem Use camera position saved in map as starting position.
playerX = TD_CamX()
playerY = TD_CamY()
playerZ = TD_CamZ()
rem Same with direction.
playerDirection = TD_CamYaw()

rem Set some spooky fog.
proc TD_SetFog 0, 32, 16, 2.0, 8.0

rem Hide mouse cursor and center its position.
_glShowCursor false
_glMoveCursor TD_GetWidth()/2, TD_GetHeight()/2
lastMouseX = mousex()
lastMouseY = mousey()



do
rem Move
dx#
dz#

rem Get mouse movement and re-center cursor.
rem Get mouse movement and re-center cursor.
mouseDX = mousex() - lastMouseX
mouseDY = mousey() - lastMouseY
_glMoveCursor TD_GetWidth()/2, TD_GetHeight()/2
_TD_Update
lastMouseX = mousex()
lastMouseY = mousey()

if keydown(VK_UP)
dx = cos(playerDirection)*0.04
dz = sin(playerDirection)*0.04
playerBobAngle = playerBobAngle + 10.0
endif
if keydown(VK_DOWN)
dx = -cos(playerDirection)*0.04
dz = -sin(playerDirection)*0.04
playerBobAngle = playerBobAngle - 10.0
endif
if keydown(VK_LEFT)
dx = cos(playerDirection - 90.0)*0.04
dz = sin(playerDirection - 90.0)*0.04
endif
if keydown(VK_RIGHT)
dx = cos(playerDirection + 90.0)*0.04
dz = sin(playerDirection + 90.0)*0.04
endif
rem Use mouse movement for direction and pitch.
playerDirection = playerDirection + float(mouseDX)*0.5
playerPitch = max#(min#(playerPitch + float(mouseDY)*0.25, 60.0), -60.0)

rem Move with collision handling. playerX, playerY and playerZ.
proc TD_Move playerX, playerY, playerZ, dx, -0.1, dz, 0.25, 1.1, 0.2

rem Set camera position and orientation.
_TD_SetCamPosition playerX, playerY + 1.0 + sin(playerBobAngle)*0.05, playerZ
_TD_SetCamOrientation playerDirection, playerPitch, 0.0

rem Render and flush graphics to window.
_TD_Render
_TD_Flush

_SPD_HoldFrame 60
until TD_Running() = false or keydown(VK_ESC, true)

In case glMoveCursor sometimes fail.

While testing the above one I realized that the mousex() mousey() doesn't get updated until TD_Update is called (that's when all window events are handled).

Just thinking out loud :) But I'd be happy if you tried the code snippets I posted, they're all just versions of example 2.

« Last Edit: December 03, 2014 by Marcus »
.\\\opz

X54321

  • Newbie
  • *
  • Posts: 38
  • I make games and cartoons. And stuff.
    • View Profile
    • Bitendo Software
Re: TD (the library and editor used for Robowack 2)
« Reply #22 on: December 03, 2014 »
I'm also thinking about workarounds. Does it become better if we don't hijack the mouse as frequently:

...

Or is the result okay if we limit the movement each frame, like:

...

Or will the player feel that there's a limitation? It really depends on what exactly is going on.
It looks as if the mouse cursor doesn't get re-centered properly every frame. Maybe you can store the new mouse coordinates after centering the mouse:

...

In case glMoveCursor sometimes fail.

While testing the above one I realized that the mousex() mousey() doesn't get updated until TD_Update is called (that's when all window events are handled).

Just thinking out loud :) But I'd be happy if you tried the code snippets I posted, they're all just versions of example 2.

OK, so showing the console didn't do anything.
The first code snippet worked perfectly in full-screen, but not in windowed mode.
The middle snippet didn't do much.
In the last snippet I couldn't move the mouse at all.

EDIT:
Actually, the first code snippet does work in windowed mode, but it's kinda jittery while you're moving.
Anyways, we're getting somewhere.  :)
« Last Edit: December 03, 2014 by X54321 »
-The Tophat Demon

X54321

  • Newbie
  • *
  • Posts: 38
  • I make games and cartoons. And stuff.
    • View Profile
    • Bitendo Software
Re: TD (the library and editor used for Robowack 2)
« Reply #23 on: December 03, 2014 »
Well, I recorded a video showing what exactly is happening.
https://www.youtube.com/watch?v=mCevHR1brok&feature=youtu.be
Again, it didn't happen in example 5 or example 1.

I looked at your video and it should not have a mouse cursor.
Look at line 63 and make sure you have: _glShowCursor false
Try moving line 63 to line 16.

 I use Windows7. Maybe your version is different?
I changed _glShowCursor to true for the sake of the video, and so you could see what was going on with the mouse.  :)
-The Tophat Demon

Marcus

  • Administrator
  • Hero Member
  • *****
  • Posts: 542
    • View Profile
Re: TD (the library and editor used for Robowack 2)
« Reply #24 on: December 04, 2014 »
Thanks for testing. That the last one didn't work says it all ... I think.I will look further into this when I'm back from work. Calling TD_Update an extra time in the top of the loop in the last code snippey might fix it.
.\\\opz

Marcus

  • Administrator
  • Hero Member
  • *****
  • Posts: 542
    • View Profile
Re: TD (the library and editor used for Robowack 2)
« Reply #25 on: December 05, 2014 »
Updated the zip (no new examples, just added cartoonish outline rendering in the md2 example), but source code of the library is now included.
.\\\opz

X54321

  • Newbie
  • *
  • Posts: 38
  • I make games and cartoons. And stuff.
    • View Profile
    • Bitendo Software
Re: TD (the library and editor used for Robowack 2)
« Reply #26 on: December 09, 2014 »
I'm really liking it so far. I've tried a lot, and I mean A LOT, of 3d engines and this one's pretty good for me.
Anyways, I have no idea what to make next, so I'm just experimenting here.
The animation of the model on the right's a little jittery, though I think this is because of the modeling program I use.
-The Tophat Demon

johnno56

  • Guest
Re: TD (the library and editor used for Robowack 2)
« Reply #27 on: December 09, 2014 »
It is not my intention to interrupt your "conversation", but I am curious, which modelling program are you using?

J

Marcus

  • Administrator
  • Hero Member
  • *****
  • Posts: 542
    • View Profile
Re: TD (the library and editor used for Robowack 2)
« Reply #28 on: December 09, 2014 »
It is not my intention to interrupt your "conversation", but I am curious, which modelling program are you using?

Nothing to interrupt, we're just trying to figure out what the heck is up with the mouse cursor ;)

I'm also very curious about the modelling program! I'm using a homemade program against my will, would love to find something better to work with. Blender is too advanced for me, I simply don't have the time to learn it. I want good extrude and subdivision tools, easy uv-mapping and an md2 exporter :)

The lib/engine is very limited, tophat, not much more advanced than the raycaster lib, but I'm glad you like it! Like, there can only be one floor, one ceiling and 4 (well 6) walls per tile, but if you combine it with a heightmap you can still manage to create some nice stuff. My best example of this is the Bambam game (video on youtube: https://www.youtube.com/watch?v=4M8LW6es8Gs).
« Last Edit: December 09, 2014 by Marcus »
.\\\opz

Marcus

  • Administrator
  • Hero Member
  • *****
  • Posts: 542
    • View Profile
Re: TD (the library and editor used for Robowack 2)
« Reply #29 on: December 09, 2014 »
I just began experimenting with 3rd person control and camera (example 6). There's nothing to say about it yet, the example is unfinished. But while working on it I turned on the outline effect when rendering my character and forgot to turn lighting off. The result, atleast in motion, looks pretty cool, almost ghostly glowing. I've updated the zip just for this ;)

 

.\\\opz