Jump to content
  • Advertisement

Exoaria

Member
  • Content count

    25
  • Joined

  • Last visited

Community Reputation

178 Neutral

1 Follower

About Exoaria

  • Rank
    Member

Personal Information

  • Interests
    Art
    Audio
    Design
    Programming

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I've been thinking a lot about how I want to approach the design for interactive objects in my 2D Platformer. I wanted to do something lightweight and centralised so I started work on an Event Class that embodied anything that would be interacted with. The type of interaction would be defined in the Unity Editor though a Custom GUI that I am working on. As you can see, this "event" would be for a moving platform. If "Is Triggered" is ticked, the Platform moves only when the player jumps onto it and activates it. Otherwise it will interpolate between the definable "Start Position" and "End Position". Depending on which "Event" (enum) is selected, the Editor properties will change and so will the behaviour of the Game Object with the event attached to it. For example, selecting "Item Collect" would mean that the Game Object is no longer a platform - no longer an object that moves when activated - it would be a stationary sprite that, when activated, would disappear and add itself into the player Inventory. Here's some code to show where I'm at with it: /* * ############################# * ##@@## INITIALIZATION ##@@## * ############################# * */ private void Awake() { SetupEvent(eventType); } public void Activate(bool calledFromTrigger = false) { if (autoTrigger && !calledFromTrigger) return; Debug.Log("Activated " + name + "!"); StartEvent(eventType); } private void StartEvent(EventType type) { switch (type) { case EventType.Movement: MovePlatform(); break; case EventType.Dialogue: break; case EventType.NPC: break; case EventType.ItemCollect: break; case EventType.Cutscene: break; case EventType.Switch: break; case EventType.Custom: break; } Don't be deceived by the snippet - this is all quite functional as of right now, but I can't help but feel I am making a mistake. I keep having this gut wrenching feeling pulling me to scrap it and rewrite the "Event" class to be a base class of "Interactible" and for each type, or what is currently an enum, to be a child of Interactible. Essentially, I am not sure whether to base my events off of one Event class, with functionality dependent on the selected "Event Type" enum... Or have the "Event Types" span multiple classes inheriting from a base "Interactible" class. I like to be able to just drag and drop, select what I want all in one place - but I feel that this is entirely impractical due to its low level of abstraction and code being all in one spot. Can I get some opinions? I am a relatively beginner programmer but I know code decent enough to be able to use more advanced techniques I think. Here is a screenshot of my game for context.
  2. https://gist.github.com/anonymous/cbff9fc74258450eb27d50db6aa8ce03 I'm trying to write code to manage an inventory in a simple way. This is the first code I've written to do this. I'm having a bit of trouble understanding certain things. For context, this is intended to be a text adventure. I have an Item class, and Weapons + First Aid subclasses. If I want to instantiate a weapon, I'll call Item sword = new Weapon("Sword") -- the Item class, as you'll see in my code, requires a name when it is instantiated. If I want to find that Item in a room I'll pass "Sword" through to DeleteItemFromRoom(string item) and check the item string (containing "Sword") against the "name" property of the Item class to see if it exists. I don't know if I'm doing it right, or if I should create a global manager, or if instead of creating new items for each room I had a table of pre-defined items and identified them by unique keys... I don't know how to do that though. So I was hoping for some advice or a nudge in the right direction. I want my code to be clean but I still want efficiency
  3. I have an inventory system that I am trying to make as part of my first programming venture. Creating the inventory doesn't seem to pose the challenge, but rather the control flow and code organisation that is needed. I have done some research, but I can't find the answers that I need. Instead, I have become confused, which you will see if you read my sheets I've been scribbling on trying to figure out how to work it. Most of the information that I think anyone would need to take part in this discussion can be found in that link. I am using flawed logic, but I don't know how it is flawed, since I am coming from the perspective of someone who is new to code and does not have a lot of experience with the optimal interactivity between functions and the logic that should be used in these situations. Essentially, I hope to gain some seeds of wisdom from someone else that may have been in my position or a nudge in the right direction from someone else who, in fact, can see where my logic is flawed and where it needs to be shifted.
  4. Since the date I asked this question I spent a vigorous amount of time learning C# and going through programming books. Even though it's been a month, I feel that I can answer this question better now. What I was looking for was a framework for C#. I didn't understand that not everyone programs a game using DirectX or OpenGL from the ground up. When using a programming language like C# -- that's all it is, just a language. A way of communicating and translating information. You can build your engine from scratch (which would be near impossible for a beginner) or use a range of libraries and frameworks created by other people for serving the bare minimum amount of functionality for the application you are trying to create. C# doesn't magically make it happen. It communicates through the Operating System and sometimes it's easier to get someone else's code and use it to translate it rather than doing it yourself. Essentially, when I asked the question, the image that I had in my head could be most closely related to XNA. It's now discontinued, so MonoGame would therefore be the answer I was hoping to get out of the query :"How do I use C# to make a game without a commercial engine?"
  5. I see a lot of indie games being released, with "Made with C# and LUA" in their descriptions. I'm curious to know how viable it is to write your games from a base level of code which is then compiled. I can't fathom how games are made without an engine. How does someone pick up C# and write games in it for those 24 hour marathons? From recent study I think it may have something to do with "Libraries", but I still don't know how it works. Specifically, I don't know how someone draws images to the screen, animates them, creates physics for certain "sprites" and does all of the other stuff that seems so easy in modern engines. Are libraries used to make this process easier? Would you recommend that someone who has a primitive but solid understanding of programming use a language as opposed to someone else's engine? I am not talking about fancy 3D games -- just the typical lightweight 2D indie games in this context.
  6. Exoaria

    Dialog and Event trees

    This reply was very constructive. This scripting language is more than powerful enough to test for an ID (or any variable) of a an NPC and can have virtually limitless scripts to reference from, or call functions from. Are you saying that I should create a separate script (such as a singleton) that will always be running, or listening, and for the NPC script to pass its parameters to a function on the external script signaling it the details it needs to make things happen? I guess my question is, how could I use that external script to manage 100 different behaviours for 100 different NPC's when they all have very different conditions? Or am I missing the point?
  7. Game Engine: Godot Game Engine Language: GDScript — Syntax very similar to Python My questions are obviously within these bounds. I am very happy with Godot as an engine; and I do not think that my limitation to GDScript prevents me from any of what I aim to achieve: many have done so before me. It is almost entirely a matter of logic and the implementation of that logic within the bounds of resources available. With that said, let me propose my problem.   I am by no means an adept and fluent programmer, but my knowledge has been sufficient enough to make games in the past and I feel that I am capable of implementing whatever structures, systems and logic trees are suggested to me with some thought and exercise.   I have created a dialog system in Godot Game Engine which I am (somewhat) happy with, but does not achieve my core goal. Keep in mind this system was completely created by me and I was not following any examples, which could contribute to why it is so awful.   The first thing to note is that this system only allows any sign or enemy to have two states of text: An intro, and if specified, a continuation of that text. An exported variable lets me check a boolean to say "This character has two lines of dialog." — Upon speaking to the character they might say "Hello [player], my name is [entity], nice to meet you!" Then be flagged to say that the character has spoken to them. Upon "activating" them the second time, the script will see that it HAS a second line of text, and then the NPC might say "It's a nice day today!"   The main core of this is done through three systems: - Checking if the player is next to an interactive object. - Passing the character details to a function which will query an external config file for appropriate dialog. - Displaying the text on screen. (This part is fine, I'm totally happy with how it turned out)   Let's say that I have a Skeleton that the player can talk to. Its external parameters are this: SECTION: GRAVEYARD (Its location) KEY: SKELETON (Its identifier) EXTENDED: True (Does this NPC have two lines of text?) The script would then query a .cfg file which contains a dictionary of text; it would look like the following. [GRAVEYARD] SKELETON = {"INTRO": " Why don't skeletons fight each other?.","IDLE": "BECAUSE THEY DON'T HAVE THE GUTS!."}   The first time the player talks to him, the script would see that it has two lines of text. It would automatically search for "SKELETON" in "GRAVEYARD" in the config file. (See above.) The script would then retrieve the dictionary value held in "INTRO" and flag the NPC such that the next time the script is called it searches for the "IDLE" dictionary value. The player then activates it again, the script sees the flag, and then looks for "IDLE" instead of "INTRO". This is the best that I could do. And it's god awful. It serves no purpose, other than to display two different mundane pieces of text.  So why don't I use the system to enable more? This is where my logic runs out. Bam. None. The way that Godot (and MANY other engines, including Unity) handle objects are through nodes. These are the equivalent to Unity prefabs. I create an object and I have the luxury of attaching a script to it, which defines the way that ALL of those objects will behave, which saves me a lot of coding. Obviously there is a ridiculously easy solution to this, but my experience doesn't allow me to think of one, which is why I am here. If the script searches for an invalid dictionary, the whole game crashes. If it searched for "IDEL" instead of "IDLE" — it's game over. (No pun intended.) So a solution would be to create a different script for each NPC in the entire game, but this doesn't work. What I need is a dialog tree which can be safely called by all NPC's in the game to get different text based on the situation. Is the player low on health? The NPC could say "You look sick!", is the player on a quest? The NPC could say "I hope you've killed those pesky Goblins!", has the player just saved someone's life? They could say "Wow, thanks for saving me!" I will probably never use such complicated trees, and my current system could pass for this game as it's only a Castlevania-esque platformer. But it does me no favours, and while it has taught me a lot, is a huge bottleneck not only for creating dialog, but for my event system (flipping switches, opening doors with keys etc.) which works very similar to the above. I have researched dialog trees, but they're all in the context of LUA/C++ which I obviously can't use. I'm pretty sure Godot supports XML but I don't think it can read XML files in the usual way — in that XML is specifically just a format for saving scripts or prefabs. I have a Config File system which can store any kind of variable or dictionary, and a surprisingly powerful scripting language that can do just about anything that Python can do. I guess the best way to describe my limitation from my point of view is that I don't know how to create a system where entities or interactive objects behave differently while still using the same script. Obviously, there are other factors, and dozens of ways around it, but I really really really need a push in the right direction. Please give me some logic advice, or ways that you tackled similar issues. Thank you so much for taking the time to read this.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!