Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 19 Dec 1999
Offline Last Active Yesterday, 10:57 PM

#5180992 RPG Maker VX Ace - 75% off on Steam

Posted by Eck on 17 September 2014 - 07:00 AM

It looks like RPG Maker is on sale until Friday 10AM Pacific. I thought some people might be interested in it, so here you go:




- Eck

#5180812 Optimization philosophy and what to do when performance doesn't cut it?

Posted by Eck on 16 September 2014 - 02:41 PM

There's not one correct answer here since software architecture isn't an exact science. If it were, there'd be one solution to a problem and we'd all just use that. :) As you gain more experience, you'll be able to identify when you should be optimizing sooner rather than later. 


Regardless of when you choose to do performance tuning, the first step is ALWAYS PROFILE THE PROBLEM. So many developers say to themselves, "Self. I know that this code right here is the problem. Let's make it faster and our problems will be solved." They spend a week making that section 10 x faster but it turns out that section was only taking 1/1000th of a second to begin with. They might even try this failed approach a few times before FINALLY timing the various sections of code and tracking the REAL problem down.


Sometimes you get lucky and you guess correctly, but save yourself some headache and profile your performance problems.


- Eck

#5180299 "Permanent" pointer-like references in C#? Or design that works for t...

Posted by Eck on 14 September 2014 - 01:39 PM

I really like Nypren's proposed solution and this may be exactly what you're looking for. He's using delegates and that funkiness in the PotionFactory is called a lambda expression which is just syntactic sugar for a delegate. Do a little bit of research on those items. If you need more help understanding it, we'll be happy to help.


@Nypren - Very slick sir. I've used delegates for similar things, and I've used lambda expressions for looping/finding logic. But this little example speaks volumes of delegate coolness. Nice job. 


For completeness, I'll go ahead and answer your question about Option 1. I thought Option 1 is what you were already doing. :)

@Eck: Thank you. I was originally doing pretty much exactly what you used for the example in Option 2, but I felt like there should be a more simple/compact way to do it.
I feel like this is similar to what you meant in Option 1 but I'm not really sure. Would it be possible for you to expand on that just a bit more?
Specifically, "If your Potion has a CharacterStats member variable named affectedStats," what type of variable would affectedStats be and what would it hold? It still can't hold a refernece or pointer, so I don't think I'm understanding this example properly. Plus every instance of Potion would have a different affected stat and I'm not sure how it would keep track of that.


CharacterStats was just a rename of your class Parameters (a giant list of stats HP, attack, defense, etc.). I just didn't like the name Parameters because I thought it would cause confusion. So, I'll switch the name back to calling it Parameters for this post.  Parameters is a class, and so it's a reference type (like a C++ pointer). In your game init code, you can new up a Parameters object for all your healing potions. Parameters healingParameters = new Parameters(/*set health to 50, set rest of variables to 0*/). Potion has a member variable: Parameters AffectedParameters;  When making a healing potion, just assign potion.AffectedParameters = healingParameters;. There's just one copy of the data of healingParameters since their reference types. Then the potion's Use() function can just add all of its stats to the character's stats. player.HP += affectedStats.HP; player.Attack += affectedStats.Attack; Since the rest of the variables were initialized to 0, the only thing that gets changed is the HP.


Again, I feel this is the hackiest of the options. It may be good enough for your needs, but... blech. :P


If you don't like Nypren's solution, you might want to look up Reflection. With reflection, you could look up a property by it's name and set its value. So you could for instance, mess with the variable named "HP".



Just be careful. Reflection lets you do things you're not allowed to do, like access private data members. There may or may not be some commented code in production that says // HAH! IN YOUR FACE OOP!!! attributed to me. >.>


- Eck

#5180267 "Permanent" pointer-like references in C#? Or design that works for t...

Posted by Eck on 14 September 2014 - 10:49 AM

You might want to start reading a little bit about Object Oriented Programming (OOP) or a Component Entity System (CES). Like Hodgman said, all class objects are pointers.
Here's a rough first stab of an OOP approach. You might have an Item base class that would hold data and operations common to all Items. Things like its name, inventory icon, quantity, etc. Potion would inherit from Item so it includes all the Item data. and override the Item's Use() method. A Potion would have potion data like Heals 20 hp / sec for 40 seconds. Using a potion consumes it and applies the effect.
Your inventory system would have a list of Items. Since Potions, Swords, Scrolls, etc all inherit from Item, they ARE items. When your player right clicks on an item to "Use" it, the inventory system doesn't know if the clicked item is a Potion or Sword. It just calls the Item's Use() method. However, the clicked item knows which specific kind of item it is. "I'm a potion, so I'll reduce my quantity by one and apply my effect".  If the Item was a sword, it might try to equip itself on the player.
And.... I should really stop answering questions when I first wake up in the morning. I see that's not the question you're asking, but I'm leaving this post up in case someone else finds it useful. So...Back to your original question. How do design your potion class...
I'm going to change the name of "Parameters" to CharacterStats for the rest of this discussion. (Option 1) If your Potion has a CharacterStats member variable named affectedStats, then you can have a potion that does anything. It's simple and powerful, but a little bit clunky. But if you have a simple healing potion that gives 20 health, you'll still have a copy of all the other stats Strength, Dexterity, Armor Class, etc. In all honesty, it's probably good enough for now.
Another option (option 2) is to code up a PotionEffect system. Create a StatAdjustmentEffect and an enum(eration) of your CharacterStats. The StatAdjustmentEffect has the AffectedStat and the Adjustment to make. When applying the potion's effect, you'd map the enumeration value over to the data of the CharacterStats class.
enum CharacterStatEnum
    // more stats...
public abstract class PotionEffect
    public float Duration {get;set;}
    // Each potion effect child class implements ApplyEffect.
    public abstract void ApplyEffect(GameCharacter potionDrinker);
public class StatAdjustmentEffect : PotionEffect // Base class for all potion effects
    public CharacterStatEnum AffectedStat {get;set;}
    public int Adjustment {get;set;}
    public override void ApplyEffect(GameCharacter potionDrinker)
            case CharacterStatEnum.Health:
            potionDrinker.Health += Adjustment;
           // More case mappings.
        // Keep up with these effects somehow. could attach them to the potionDrinker or potionEffectManager class. 
        if(Duration > 0)
             throw new NotImplementedException(); 
Then your Potion class can have a List<PotionEffect>. It's powerful, clean, but more complex. However, this system allows for an easier expansion into things like an Invisibility potion.
Another option (option 3) would be to include some sort of scripting library, and a potion can have the script that should run when the potion is drunk. This could be argued to be more or less complex than option 2, but you won't know until you get into it.
These are the types of design problems that make programing so fun ... and frustrating. There isn't just one correct answer and even Option 1 should be seriously considered. It might be simple enough to get the job done and you can move on to features that add more coolness than a robust potion featureset.
- Eck

#5180078 Which basics do you need to know

Posted by Eck on 13 September 2014 - 08:54 AM

It looks like SFML is a good choice for C++ as well. On the first page of the For Beginners forum, there's a post labeled C++ Starter.




- Eck

#5180076 Which basics do you need to know

Posted by Eck on 13 September 2014 - 08:50 AM

You couldn't find an answer to that question because the question is so broad. For the simplest of games like "guess a number", you need to understand variables, receiving input, displaying output, looping, and branching. For something like a Pong clone, you wouldn't need much more than that, you're just working with graphics instead of text. Receiving input becomes reading the mouse position instead of reading the number they input. Things like functions will help (once you understand them) but "technically" aren't necessary.


But in short, all of the fundamental features of a language are needed for anything with complexity: variables, data types, data structures, looping, branching, functions, data structures, mathematical operators, and boolean logic. Once you begin to understand those building blocks, anything is possible. And at that point, you'll probably want to look into design paradigms like Object Oriented Programming, or Component Entity System.


I recommend just jumping in with game programming tutorials. Just be prepared to go back to basic tutorials that cover if/else statements when necessary. You might have an easier time starting out with something like C# and Mono Game or Unity. (I'm sure there are C++ options available too, but lately I've been recommending new developers go with C#) You'll be able to get something showing on the screen very quickly. Making a ship move around on the screen is much more motivating than guessing the correct number. And motivation will likely be your biggest hurdle early on. Here's a link to one of my motivation responses: http://www.gamedev.net/topic/657143-staying-motivated-while-learning-advice-needed/?view=findpost&p=5156722


Or you can go with a game builder application like GameMaker Studio or RPG Maker and make games without ANY* programming knowledge.


* - Programming knowledge will GREATLY help.

#5179706 Card Zone placement problem

Posted by Eck on 11 September 2014 - 04:19 PM

Chadook, can you explain your algorithm a little better for us? Walk us through it with pseudocode/english.


When does this code get called? 

What are the x, y variables? Is it the position of the card? The position of the mouse? Something else?


I'm guessing obj_mzone1 is the far left pink square, and obj_mzone2 is the next pink square to the right. Correct me if I'm wrong.


- Eck

#5178058 preloaded Images vs. rotated Images

Posted by Eck on 04 September 2014 - 07:47 AM

I don't think RAM is going to be an issue. Let's say you have 5 different zombie sprites, and you put up 100 zombies on the screen, 20 of each type. There's only 5 copies of the sprite in memory with 20 references to each.


Performance won't be an issue either since computers are so darn fast. Rotating a sprite with a matrix operation vs. having different direction sprites will be negligible. You'll be better off making this decision based on other factors such as: look and feel, art resource complexity, etc.


- Eck

#5178054 wanna publish a game, but keep my privacy intact

Posted by Eck on 04 September 2014 - 07:21 AM

Well, I have yet to hear of an indie game developer who is swarmed on the street by mobs of teen girls... I think we're pretty safe from that. :)


Now the question: "Can I sell a game without selling myself?" Sure. I've bought games without knowing who coded them, and you probably have as well. It's not a requirement to put yourself on display in order to sell your games.


That being said, some form of advertising is recommended. If people don't know about your game, they aren't going to buy your game. Many people go the Facebook/public blog route because it's free and they can generate a small community before even releasing. It works for some people, but not everyone. Do some research on marketing indie games. There are plenty of other ways to advertise besides giving people a window into your life.


- Eck

#5176657 Line vs Triangle collision in 3D

Posted by Eck on 28 August 2014 - 07:19 AM

Careful using this method with computers though since floating point numbers aren't perfect. There's likely to be some rounding error when calculating the sums of the triangles' areas.


Here's an article that explains how another algorithm works. 




I'd have shared it earlier, but it has a C++ solution at the end and I wanted to make sure you weren't "cheating". :)


- Eck

#5175736 How to program tile transitions (C++/SFML)

Posted by Eck on 23 August 2014 - 09:10 PM

This article is about transitioning terrain tiles:



And this forum post explores it a little further:



I think they'll shed some light on your problem.


- Eck

#5174834 Staying Motivated

Posted by Eck on 19 August 2014 - 03:08 PM

Yeah, being an indie game developer is rarely the path to riches. In fact, it usually costs you lots of time, effort, time, socialization, time, money, and time. But if you do finish a game, release it, and even one person (not a friend or family member) buys your game. You get to say... "I'm a professional game developer!" :)


- Eck

#5174583 Staying Motivated

Posted by Eck on 18 August 2014 - 05:50 PM

First of all, you should realize that staying motivated is a pretty common problem. You're not alone. There was a really good post that lots of good advice on how to stay motivated. Here's a link to my post. 



Watch the movie Collateral! :)


Focus on smaller games at first. There's a great article on which game you should code first and why.



If you go straight to your dream-game of awesomeness, you'll quickly get overwhelmed. But if you take baby steps of small reasonable goals you'll be rewarded with a sense of accomplishment and be equipped with tools and code to tackle bigger projects.


If you can stay motivated to get into shape, I'm pretty sure you can stay motivated to work on game development. It sounds like you have a pretty busy life right now so the time simply might not be there.


The only "trick" is, that there isn't a trick. You have to prioritize it or it just won't happen. You have to want to lose weight more than you want to eat donuts. You have to want to complete a game more than you want to play a game. :)


Good luck man,

- Eck

#5173006 Can't solve problems without googling?

Posted by Eck on 11 August 2014 - 09:39 PM

You will do a lot of things wrong over your career.  You will try something and it will fail. You will start down one path and realize you could have done something much better...


You'll probably also solve a problem one day and say to yourself, "Damn. Now THIS is some awesome code."  Then a few years later you'll look back at that work and laugh at past-Lith for being such an ignorant newbie. 


Like others have said before, you'll get better through practice. Since you're 17 and started programming a couple of years ago, I wouldn't worry too much about it. You're motivated to learn and are programming in your free time. Good job.


And one reason the solutions look easy online is because you're looking at the solution. You're not watching a video of some mathematician staring at a whiteboard for hours at a time, trying and failing a hundred different times. You get to see his nice proof on a clean sheet of paper without any scribbles or teardrop stains. :)


- Eck

#5171096 Where should I start? (2D Game Programming)

Posted by Eck on 02 August 2014 - 08:33 AM

Ah... At first you said  "a simple 2d game where my friends and I can chat" and then you drop the term "We're going to make an mmorpg"...  Ugh...


Go read this article right now:



Read the whole thing! >.<


And don't knock using game engines or higher level languages. Read this one too:



Especially #2 where he talks about using game engines and languages. He even points out that Minecraft was made in Java.


- Eck