Jump to content

  • Log In with Google      Sign In   
  • Create Account


SonicD007

Member Since 23 Feb 2006
Offline Last Active Jun 23 2014 06:41 PM
-----

Topics I've Started

Unity 2D tiled maps

20 June 2014 - 04:09 PM

Is there any easy way to create tiled maps in unity 2D?  If not, I would like to use tiled to create a map in the tmx file format to then import that tmx file into unity.  I realize I'll probably have to create an importer for unity to be able to understand the file but I'm not sure how to create custom importers for unity 2D.  Is it only available in the Pro version?


Gamedev has shown me how I've grown

08 December 2013 - 07:50 AM

Hey everyone.  Today I wondered how long I've been programming for.  I started roughly around when I joined this website, so I decided to take a look at when I joined.  Apparently it's been 6 years and I still haven't put out a 2D game similar to Zelda which is my goal.  I have however created a windows phone game, tetris, pong, various tools, and I've learned a ton of information.  What's funny is you can see my first post on gamedev and my posts looked just like the new guys that are posting in the For Beginners forum now.  "Hell I even started a DirectX or OpenGL?" thread back then!  I just found it interesting to see how much I've grown as a programmer (and somewhat in maturity based on my posts that look like a 7 year old wrote it!).

 

Anyone else notice this about themselves? (specifically with your posts on gamedev)


Input handling design frustration

06 December 2013 - 11:19 AM

So I've been reading through this article and messing with it for close to a month (on and off because of work and school) and I understand it for the most part.  I changed the code a bit so I could use SDL_Keycodes for the SetRawButtonState methods and whatnot and got all that working.  My problem comes with the function pointer that InputMapper uses to do any actual work based on the input.  Most likely my brain is just overworked and I can't properly think this through...

 

So, how would I have my gameObject handle the input that is received?  I want the individual game object to act on the input that was received so how would I do this exactly?

 

Would I need to do something like this?  If so, how can I also pass the struct that inputMapper uses that holds the information on the actions and states?

 

inputMapper.AddCallBack(gameObject.HandleInputFunctionPointer, 0);

 

P.S. I'm rusty with function pointers so that could be my issue.
 


Sprites and states

31 August 2013 - 01:43 PM

I was wondering how people organize the sprites that correspond to certain states such as walking left, walking right, etc.  I have a sprite sheet that has sprites all unorganized in it so I was thinking of taking each animation and putting it into its own file such as walkingLeft.png  

 

Do you guys put your sprites into their own image file, hard code each sprite animation frame, or do you organize your sprite sheet in a way where each one has to have x amount of frames per state and you just organize the rows by states?


Object Oriented Design Menu System

21 June 2013 - 01:51 PM

Hello everyone.  I've been programming for a few years and have had enough with my brain not grasping Object Oriented Design and creating classes that aren't decoupled.  I went back to the beginning and took a look at Project 1 in the CPP workshop (http://www.gamedev.net/topic/409907-c-workshop---project-1/).  Now, I created a very loosely coupled class which is good (ignore the fact that there are no error checks and does not sanitize user input)....

 

TextMenu class


#include "TextMenu.h"
 
TextMenu::TextMenu()
{
}
 
TextMenu::TextMenu(std::string title, std::vector<std::string> textEntries, IMenu* parent)
{
this->m_title = title;
this->m_textEntries = textEntries;
 
if (parent != 0)
{
this->m_parent = new TextMenu();
this->m_parent = parent;
}
}
 
 
TextMenu::~TextMenu(void)
{
if (this->m_parent != 0)
delete this->m_parent;
}
 
void TextMenu::Display()
{
std::cout << "===========" << m_title << "==========" << std::endl;
std::cout << "\n";
 
for (int i = 0; i < m_textEntries.size(); i++)
{
std::cout << i+1 << ". " << m_textEntries.at(i) << std::endl;
}
}
 
int TextMenu::GetInput()
{
std::cout << ">";
char input;
std::cin >> input;
 
return atoi(&input);
}

....And it follows the Single responsibility rule.  The only problem is all the logic for deciding what to do with the user input falls upon the main() code.  This in turn results in a nasty looking switch statement that looks to me to be a very very poor way of doing things....

 

Main

#include <iostream>
#include <string>
#include <conio.h>
#include <vector>
#include "TextMenu.h"
 
using namespace std;
 
int main(int argc, char* argv[])
{
vector<string> entries;
entries.push_back("Create Character");
entries.push_back("Shop");
entries.push_back("Quit");
 
TextMenu test("Main Menu", entries, 0);
test.Display();
 
switch (test.GetInput())
{
case 1:
entries.clear();
entries.push_back("Name");
entries.push_back("Class");
entries.push_back("Economic Status");
entries.push_back("Back");
 
TextMenu charCreation("Character Creation", entries, &test);
 
charCreation.Display();
if (charCreation.GetInput() == 4)
charCreation.m_parent->Display();
break;
}
 
_getch();
return 0;
}
 

So, what would be the best way of dealing with this?

A) Have the menu class handle the input by somehow creating handlers and attaching them to each menu entry.  (I'm thinking of .NET and how for example the button gui item simply has a button.Click() Event that gets triggered.  Not sure how to do this event delegation in c++ though)

 

B) Keep the logic out of the menu class but somehow I would have to clean up that main() code.  It looks horrible as it is and I know it's a poor design, but I'm not sure how to fix it.

 

How would you guys fix this problem?  Please keep in mind I want to improve my OOP design skills.  Ignore the fact I don't have any error checking and the main() code was created as a draft to test my class.  I'm leaning toward answer A to solving this issue but I'm open to how others would do this.

 

Thanks.

 

P.S. I'm not a beginner in C++, just can't seem to grasp the design aspect of programming well :/

 

EDIT: Seems like the code tags don't like my tabs/spacing o.0


PARTNERS