GML Help with multiple issues please.

Discussion in 'Programming' started by Lugiafan123, Sep 12, 2019.

  1. Lugiafan123

    Lugiafan123 Member

    Joined:
    Sep 9, 2019
    Posts:
    7
    Hope I'm postimg this in the right place but here we go.
    As the title says I need help with multiple issues and problems. I'm currently in the process of making my first game and have managed a little bit. The main issue I'm grappling with right now is how to make room transitions work. I can make the character move between rooms but the problem is I haven't figured out how to keep his position consistent. Right now the player simply appears in the same spot no matter from where he entered the room from. Anything I've tried to alleviate this has only resulted in a fatal error message. If needed I can go into more detail and display my code.

    My second problem requires me to go into more detail and so I shall. The game I'm making is going to be a turn-based RPG. My second issue is I haven't yet figured out how to make character creation work. At least not how I envision the class system for this game. In a nutshell the idea I got for the class system was to make your characters alignment affect what skills your character can learn. There are six alignments I've come up with. You choose your alignment at the start of the game and as previously stated this should affect what skills your character gets access to as they level up. The problem is I haven't figured out how to actually code this feature into the game.

    The last issue is more of a problem for the future but eventually I will have to figure it out. Due to the nature of this game I will have to learn how to code a save and load feature into the game eventually.

    These are the main problems I could use some help with and would really appreciate if someone could help me out. I can go into more detail if required but until then see ya.
     
  2. nesrocks

    nesrocks Member

    Joined:
    Nov 6, 2016
    Posts:
    298
    Issue 1: Have you made the character "persistent" and added him only once in the game (don't add him on every room)?

    Issue 2: Infinite ways to do this. I'd work with vars and arrays. So if you have chosen path "2", then you get "allskills[2]" which itself is an array of skills. So at game setup you create
    Code:
    var skills0 = [jump, fight, magic];
    var skills1 = [hunt, fly, swim];
    var skills2 = [craft, cure, heal];
    etc
    allskills = [skills0, skills1, skills2];
    Issue 3: There are save scripts on the marketplace, take a look!
     
  3. Lugiafan123

    Lugiafan123 Member

    Joined:
    Sep 9, 2019
    Posts:
    7
    Thanks for the help the array idea sounds good to me. You seemed to have hit the first part of the problem dead on as I made the mistake of placing an instance of the player in every room so far, but I can probably correct that.
    The problem then becomes how to make the game know where the player object is supposed to go after moving into a new room.
     
  4. nesrocks

    nesrocks Member

    Joined:
    Nov 6, 2016
    Posts:
    298
    You will either need to set a helper object (with an empty draw event so it is invisible at runtime) on every room so the player's object can be moved towards it when the new room is loaded, or you will need to set spawn coordinates for every door you enter. Either way it's not going to be fully automated, it's going to be laborsome for you. Unless you have a very simple behavior for repositioning every time, which I doubt. On rooms the player can only enter from one door it's easy, just go the helper object way.
     
  5. curato

    curato Member

    Joined:
    Jun 30, 2016
    Posts:
    391
    Yes having a manager object that created global variable and manages overall game stuff that wouldn't be logical to put in another object is the way to go. You just need to have what ever object you are using to leave the room have properties (ie variables without the var in front) that indicate which room to move to and the x and y of the spawn position. (you can use the same object here and reset the properties in the creation script if need be.) Then when you activate the room change you pass the properties to globals created by your manager object then execute the room change. Then in the room start event of the manager object you can create the player object at the x and y you specified in the room change object.
     
  6. Lugiafan123

    Lugiafan123 Member

    Joined:
    Sep 9, 2019
    Posts:
    7
    Me again and could use some help with figuring out something. I found out what was causing the fatal error on startup. The current problem causing the game to crash is that the gamestate object expects an instance of the player object in the room containing the title screen. Now for obvious reasons the player object isn't supposed to be on the title screen, at least to my knowledge. The good news is that I tested the transition system and it seems to work with spawn coordinates in the gamestate object, the problem is of course that the code makes the game expect an instance of the player object on the title screen. Or more specifically it expects an instance of the player in the same room as the gamestate object first spawns.
     
  7. nesrocks

    nesrocks Member

    Joined:
    Nov 6, 2016
    Posts:
    298
    Use the "instance_exists()" function as a condition before running the code.
     
  8. Lugiafan123

    Lugiafan123 Member

    Joined:
    Sep 9, 2019
    Posts:
    7
    Thanks again, It may be obvious but I'm kind of a novice when it comes to coding. Kinda have to be since I'm self-taught.
     
    nesrocks likes this.
  9. Lugiafan123

    Lugiafan123 Member

    Joined:
    Sep 9, 2019
    Posts:
    7
    Now it seems I've run into another problem. I've started implementing the skill system but I've immediately run up against a problem. This time I can tell exactly what the problem is though. I don't know how to solve it though.
    The problem is that the game only references the variables within the array once and I don't know where to go from there. I have set up the framework for a switch statement that is set to do something when I select the options from the menu.
    I'm thinking this could solve the problem if i code the arrays into the switch statement but I have no Idea how to do it correctly if this even would solve the problem.
     

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