Build 3D games with Construct

0 favourites
From the Asset Store
Template for a basketball game with a 3D aspect (illusion of 3D)
  • Really cool! <img src="smileys/smiley32.gif" border="0" align="middle" />

  • Another note on speed: Every click creates a new explosion of particles, so be careful clicking madly. ;) Also, Chrome seems to run the fastest (obviously). Don't even bother running this in IE (in fact, let's just pretend it doesn't exist in my world space. LOL).

  • Hey guys, check out this cool game created by russpuppy using the Pseudo 3D game example! :)

    http://www.kongregate.com/games/Russpuppy/photo-collection

  • that's amazing work :) very good example too :)

  • This is indeed very cool, JoyfulDreamer.

    I've been messing around with the engine and most of it is really easy to use.

    There's just one thing. I want my player to shoot an object, so I create an object at CameraX, CameraZ. The problem is I can't figure out how to calculate the angle of movement for the object, so that it fires in the direction of the current view.

    Do you have any ideas as to how to solve this?

  • Hi RuneS,

    Here are some points to keep in mind:

    1. Objects in the tutorial project never move (though they could).

    2. The camera (player) starts at 0,0,0 (and 0 rotation) - so that means the obejcts you see on screen have NO translation applied (other than perspective and size for the view)

    3. As the camera (player) moves, the camera location is simply subtracted from all object positions in the world to find their new positions relative to the player's movement (the objects x,y,z never change in this case).

    So, let's assume the player NEVER moves. The player (camera) is at 0,0,0 (z,y,z) facing angle 0 on the Y axis (straight down Z+) and thus if you create an object at 0,0,0 and fire it down Z+, it will work. The trick then is to start at the player's (camera's) position, so that when the camera's position is subtracted from the objects position, it begins at the translated position of 0,0,0. ;) More direct to the point, just make the projectile start at the player's position and create a 3D direction vector facing the direction.

    First, you need a non-translated direction:

    X=0

    Y=0

    Z=1

    This is a "normalized" vector (no absolute values > 1 [so you can multiply it against values for magnitude]) facing down Z+. If the player never rotates, this is all you need! :) However, when the player turns, you need to rotate the vector. I have the functions there for you already:

    newX = RotateXZForX(X, Z, CameraYRotation)

    newZ = RotateXZForZ(X, Z, CameraYRotation)

    (Y is 0, unless you want to angle an object up or down [in which case there are functions for that as well])

    Note: NEVER change X or Z before the second line (before newZ is set), otherwise madness will ensue! :)

    Hope that helps! When you get your game finished, post a link here. 8)

  • Hi again JoyfulDreamer

    Thank you for that thorough explanation. I thought I'd share my experience here.

    I did manage to get a Z-direction from your instructions. But then I couldn't figure out how to use that to determine the bullet objects direction. I'm terrible at math <img src="smileys/smiley5.gif" border="0" align="middle" />

    I did however find a solution to my problem <img src="smileys/smiley1.gif" border="0" align="middle" />

    While I was testing and things didn't work, I became more and more annoyed that I couldn't use the standard behaviors built in to C2. Then it occured to me, that that maybe I could. If I made a player controlled object with the behaviors and then set CameraX, CameraZ and CameraYRotation to the objects X,Y and angle. And whataya know, it worked <img src="smileys/smiley4.gif" border="0" align="middle" />

    I had to fiddle a bit, but it did.

    What this means is, that I could make any kind of 2d game (as long as it's top down) and use your engine to generate a 3d layer. Now I really love your engine!!!

    Here's a small demo:

    db.tt/e4k143Jm

    Not at all finished, so please be kind. use arrow keys and ctrl to shoot

  • Wow nice job! :) You should keep the movement keys operating on X and Z only, and rotate with the mouse - perhaps even aim and shoot with it as well. ;)

    What you're doing is controlling the camera. I thought your problem was firing a projectile from the camera. ;) When you have to shoot something, you'll need to follow my previous post. I'll see if I can implement a shooting example and upload the project file again if I can get some time.

  • Wow nice job! :) You should keep the movement keys operating on X and Z only, and rotate with the mouse - perhaps even aim and shoot with it as well. ;)

    Thank you very much:)

    I've made a new example here: db.tt/MxgDcMi9

    Mouse controls left and right and shoot, WASD for x,y and strafe. Shift to run. M to turn map on and off

    What you're doing is controlling the camera. I thought your problem was firing a projectile from the camera. ;) When you have to shoot something, you'll need to follow my previous post. I'll see if I can implement a shooting example and upload the project file again if I can get some time.

    No I don't! :)

    Since the camera is now always positioned relative to my player controlled sprite, I can just spawn a bullet from that sprite, then make an object in the 3d representation whose WorldX and WorldZ is the same as the bullet's x and y (and update those every tick, of course).

    In my example all game functionality is happening in the 2d map, and the 3d is just sort of an overlay..

    By the way what kind of fps do you (or anyone else) get? I get between 17 and 25 fps which I think is pretty close to acceptable.

  • Oh I see, you are using the native C2 functions to manipulate a virtual 2D world then translating an "XY" plane onto the "XZ" plane. :) Great idea.

    The controls are getting better, but for the mouse, you may want to make the rotation angle directly proportional to the mouse's X position and see if that helps.

    Assuming the FPS is the number at the top, I get 15-24.

    I never optimized the tutorial example to be an engine, but people are using it like one. LOL! ;) There's probably many ways to speed it up, but I'd rather build a plugin once Scirra supports 3rd-party plugins in the arcade. If anything, it would just be fun to do. 8)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Yes, that's exactly what I'm doing. I think it adds tremendous flexibility to work that way.

    I haven't really ever played these kind of games, so I didn't know how the mouse was supposed to react <img src="smileys/smiley36.gif" border="0" align="middle" /> . I've changed it now so that the movement is proportional to mouseX. However this causes the problem that you can't keep turning when the mouse reaches the end of the screen. Don't really know what to do about that...

    Yes I'm using your example as an engine. Because I can <img src="smileys/smiley2.gif" border="0" align="middle" />

    I was actually just thinking that it would be awesome to have a plugin to handle this. So if you think it would be fun, I really encourage you to make it. <img src="smileys/smiley4.gif" border="0" align="middle" />

  • True, if the mouse can't be "captured" then that might make it a bit odd. It might be better to keep Q and E for rotation (just make the rotation fast) and simply use the mouse to aim and shoot instead. ;)

  • Very cool guys.     <img src="smileys/smiley1.gif" border="0" align="middle" />

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)