1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GM:S 1.4 I Need Help With Fake 3D 2D First Person Engine

Discussion in 'Programming' started by RayGame, Jan 31, 2017.

  1. RayGame

    RayGame Guest

    I have been working on just the fake 3D engine of my game for days now and can't seem to create the view in the video below. I think I have figured out how to scale the sprites correctly. I can't seem to figure out how to rotate the world sprites. I can only slide world sprites on the x axis to the left or right depending on which player object rotation keys are used. I'm a but confused on how to duplicate how the video does full 360 rotation so the player can see objects in front or behind, and how to actually make the world objects look like they are rotating.

    Once my facingDir variable hits 360 or -360 it gets reset to 0. I'm not sure if this is part of the problem, but I don't see any other way to fake a full 360 rotation and have accurate readings.

    [View script]
    if x>obj_player.x //Draws sprite if in front of player
    //Scaling Size Limit
    if obj_player.scaling>=4
    else if obj_player.scaling<=1

    [Code used by world objects to access view script]

    [Player create event code]

    [Player step event code]

    //Restart Game
    if keyboard_check_pressed(vk_tab)
    //Rotate Limit
    if facingDir>360
    else if facingDir<-360
    //Rotate Left - Rotates Right View - Negative facingDir
    if keyboard_check(ord('A'))
    //Rotate Right - Rotates Left View - Positive facingDir
    if keyboard_check(ord('D'))
    //Move Forwards
    if keyboard_check(ord('W'))
    //Move Backwards
    if keyboard_check(ord('S'))
    //Stop Movement
    if keyboard_check_released(ord('W')) or keyboard_check_released(ord('S'))
    //View Sector Tracking - Positive
    //Positive - North
    if facingDir>0 and facingDir<45
    //Positive - North West
    if facingDir>292.5 and facingDir<315
    //Positive - West
    if facingDir>225 and facingDir<270
    //Positive - South West
    if facingDir>202.5 and facingDir<225
    //Positive - South
    if facingDir>135 and facingDir<180
    //Positive - South East
    if facingDir>112.5 and facingDir<135
    //Positive - East
    if facingDir>45 and facingDir<90
    //Positive - North East
    if facingDir>22.5 and facingDir<67.5
    //View Sector Tracking - Negative
    //Negative - North
    if facingDir<0 and facingDir>-45
    //Negative - North East
    if facingDir<-22.5 and facingDir>-67.5
    //Negative - East
    if facingDir<-45 and facingDir>-90
    //Negative - South East
    if facingDir<-112.5 and facingDir>-135
    //Negative - South
    if facingDir<-135 and facingDir>-180
    //Negative - South West
    if facingDir<-202.5 and facingDir>-225
    //Negative - West
    if facingDir<-225 and facingDir>-270
    //Negative - North West
    if facingDir<-292.5 and facingDir>-315

    [Player draw GUI code]
    //Draw Labels and Variables
    draw_text(20,40,'View Sector')
    //View Sectors
    if viewSector=1
    else if viewSector=2
        {draw_text(160,40,'North East')}
    else if viewSector=3
    else if viewSector=4
        {draw_text(160,40,'South East')}
    else if viewSector=5
    else if viewSector=6
        {draw_text(160,40,'South West')}
    else if viewSector=7
    else if viewSector=8
        {draw_text(160,40,'North West')}

    I only want to use 2D math / functions for this project.

    My Project Screenshot:

    Fake 3D Test:

    Project File:
    Last edited by a moderator: Jan 31, 2017
  2. oliverr

    oliverr Member

    Feb 24, 2018
    Did you have any luck with finding a solution? I'm in a similar situation and am looking to develop some pseudo 3D stuff.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice