First cut of 3D multiplayer FPS

using another iPad for the moving player…

(don’t laugh, animation is hard)

Thanks to @JakAttak for his socket library

A lot of time and effort is still needed to add features, while keeping the frame rate up, but it works! Now I know a 3D FPS can be written in Codea.

Well done, the 1st 3D Codea online game?

@Ignatz could I take a look at the code

@Archimedes - sure, just let me tidy it a bit first

@Ignatz - cool. All that’s left is for you to invite us in your castle so we could go medieval with claymores and spears.

lol, I could have a castle instead, but if it’s going to be an FPS, I need to keep the speed up, so I kept the shapes square rather than round (fewer vertices and less work for the shaders).

I’ll post the code for anyone who’s interested, but first I need to add a couple of things.

Since the video above, I’ve added a weapon, sky and zoom.

When you code a 3d game, do you have the camera move like is done in a game engine or does the world move relative to a fixed camera. To look left the world actually turns right with the camera as the axis

To quote Futurama

“The engines don’t move the ship at all. The ship stays where it is and the engines move the universe around it.”

This is an animator’s joke, because after everything has been adjusted, the camera is at (0,0,0) and OpenGL has rotated everything else to position it correctly relative to the camera. But it does this, you don’t have to worry about it.

The camera command has nine numbers, being three vec3. The first one is the camera position, and it can move about (in my FPS, it is given the player’s current position). The second vector is where the camera is looking, and the third one is the up vector, which I explain here.

My 3D ebook below also explains how 3D works in detail.

I have an idea for a collision system
You have two 2d planes each representing a dimension of the 3d map
One is a top down view of the map and the other is a side view. As the player’s x and z position changes in 3d, so does a point representing the player, except only in the 2d left/right forward/backward. This 2d point Ray casts against 2d walls. If the point gets too close to the walls in 2d, the 3d player will stop moving in that direction, same with the up and down 2d map

Essentially we would not be calculating physics in a 3 dimensional plane, but in 2 (maybe 3) 2 dimensional planes. One for forward/back, left/right, and two for up and down. The reason for two up and down planes is to allow for variations in the height of the ceiling. One plane would be the ceiling mapping of the world “viewed” from the front. The second is from the side.

@Archimedes I had the same idea some time ago, but quickly realized that that wouldnt work very well due to different terrain heights at different depths. Perhaps if it was simplified to only calculating for one slice (per plane) of the world the player is in at a certain position with three 2-dimensional planes it would work, but i thought then that having three physics systems running at a time would be more difficult and costly to manage than a skilled programmer’s 3-Dimensional physics solution.

Ray casting is extremely slow.

Because Codea’s screen is just a mess of pixels when drawing is finished (there are no identifiable objects) you have to have a map in memory of where everything is, and test every pixel in a number of directions until you hit something

The fastest alternative I managed was drawing a horizontal slice of the scene to an image in memory using a shader and using coded colours to indicate objects, and then reading all the pixels. But I could only manage one slice.

But the only practical solution is to have a memory map, preferably tile based, so you can simply calculate which tile you’re in ,look up what is in it, and act accordingly. This solves potential problems like recognizing game pickups such as health and ammo, or the jump pad which is flat.

Basically, you have to cheat as much as possible to keep things moving fast, and the professional do this too.

How hard would I be to port your wraiths from wraiths in the mist into this new game.

Your game reminds me of the old marathon game. Anyone here ever get a chance to play with that?

easy, they are just flat sprites

(I can’t believe this is even possible…)

I’m more thinking of the “AI” you set up for the wraiths. Often with code it isn’t as simple as cut and paste from program to program.
Though if this had the wraiths then we could have a survival game on our hands.

I would love to help out where I can but I cant offer much help with graphics 2d or 3d, I’m clueless in those areas.

Your game reminds me of the old marathon game. Anyone here ever get a chance to play with that?

Oh yeah. Great game. Pre Halo Bungie. You can get it for free for the iPad. Nostalgic :slight_smile:

Bingo, i wanna be a top user or player of the 3D multiplayer FPS