• Content count

  • Joined

  • Last visited

Community Reputation

145 Neutral

About AnthonyVelazquez

  • Rank
  1. Making my game code cleaner/easier to work with

    With this in a header file, every cpp file that includes it is going to get its own internally-linked copy of the variable named GameState. This is probably not what you want. Why does this variable need to be in the header, anyway? I searched for it in your github, and I only saw it in GameEngine.cpp. I suppose that's why you haven't noticed any bugs yet.   Didn't notice that issue. Thanks for pointing it out.  I honestly can't remember why I put it there.
  2. Hello, so for the past week I have been working on a 2D SFML game written in C++ but the more I program, the more it starts to get disorganized. Aside from how I name my methods. I feel like my code is all over the place.   Github Project:   There are alot of files so for an easy example of what im talking about, look at my GameEngine and stdafx files since I feel that's where the source of my problem is. Also is there anything I could remove and incorporate into Lua? I hear alot of people use it for their game logic instead of hardcoding it into the game. Any advice would be appreciated.     GameEngine.cpp #include "stdafx.h" #include "GameEngine.h" GameEngine::GameEngine(void) { GameState = Uninitialized; GameTitle = "2D SFML RPG"; ScreenWidth = 1920; ScreenHeight = 1080; Section = 0; GameView.reset(sf::FloatRect(0,0,ScreenWidth,ScreenHeight)); GameView.setViewport(sf::FloatRect(0,0,1,1)); } void GameEngine::Start() { if(GameState != Uninitialized) return; GameWindow.create(sf::VideoMode::getDesktopMode(), GameTitle); GameWindow.setFramerateLimit(30); GameWindow.setVerticalSyncEnabled(true); Running = true; GameState = State::Title; Loop(); } void GameEngine::Loop() { while(Running) { GameWindow.setView(GameView); GameWindow.clear(); Event(GameState); switch(GameState) { case State::Title: Menu.Show(GameWindow); break; case State::CharacterCreation: CCreate.Show(GameWindow); MapLocation = Location::HomeTown; break; case State::Play: MapSelection(); break; } GameWindow.display(); } } void GameEngine::Event(State GState) { while(GameWindow.pollEvent(event)) { if(event.type == sf::Event::Closed) Running = false; switch(GState) { case State::Title: Menu.Event(GameState,Running,event,GameWindow); break; case State::CharacterCreation: CCreate.Event(GameState,Running,event,GameWindow,Character); break; case State::Play: GameMap.Event(GameState,Running,event,GameWindow,GameView); Character.Event(event,GameWindow,GameView,PlayerLocation); TestNPC.Event(event); break; } } } void GameEngine::MapSelection() { switch(MapLocation) { case Location::HomeTown: GameMap.Show(GameWindow); Character.Show(GameWindow); TestNPC.Load(MapLocation); TestNPC.Show(GameWindow,PlayerLocation); break; } } GameEngine::~GameEngine(void) { } GameEngine.h #pragma once #include "MainMenu.h" #include "CharacterCreator.h" #include "Map.h" class GameEngine { private: sf::RenderWindow GameWindow; sf::Event event; sf::View GameView; int ScreenHeight; int ScreenWidth; int Section; char *GameTitle; bool Running; sf::Sprite PlayerLocation; MainMenu Menu; CharacterCreator CCreate; Map GameMap; Player Character; NPC TestNPC; Location MapLocation; public: GameEngine(void); ~GameEngine(void); void Start(); void Loop(); void Event(State GState); void MapSelection(); }; stdafx.h #pragma once enum Location {HomeTown, Dungeon1}; static Location MapLocation; #include "targetver.h" #include <stdio.h> #include <tchar.h> #include <string> #include <iostream> #include <fstream> #include <SFML\Graphics.hpp> #include "Player.h" #include "NPC.h" enum State {Uninitialized, Splash, Title, CharacterCreation, Play}; static State GameState; static sf::Color Red = sf::Color(255,0,0); static sf::Color Black = sf::Color(0,0,0); static sf::Color White = sf::Color(255,255,255);
  3. Terrain Generation

    Currently im working on Terraria clone in SFML and was wondering how I should approach terrain generation. After looking into it for a bit I found libnoise and was able to create this heightmap:   The problem is I dont know how to proceed after that. I dont know how to turn it into a 2D form of terrain and then be able to turn it into something I can use tiles with like a numerical array.   I dont know if im making this harder than it seems but I was also thinking of randomly filling a 2D array and using that for my terrain instead but I dont know how to limit the range that certain blocks may appear on for example like grass only being at the top, etc.   If you can help me with my suggestions or have any of your own, your help will be appreciated.
  4. Other Uses for Graphic Libraries

    Um, what?   Sorry now that im reading it again, it sounds stupid. What I was trying to say rather than use graphics to create games use them to create programs like Blender, GIMP, Paint, etc where the use of graphics is still incorporated but not specifically for gaming.
  5. So the main thing that comes to mind well for me at least when it comes to graphic libraries is incorporating them to create video games. Anyone know of examples that use them for other purposes? Im asking because being that my art is abysmal and I dont have the patience for it, rather than create a game I would enjoy and have more fun making an actual program like Blender as an example that may incorporate it in some way. Any help or pointers in the right direction will be greatly appreciated.
  6. Creating Pixel Art

    Hello, can anyone guide me in the right direction for creating pixel art in the style of these 3 examples?   Any help would be appreciated.
  7. Sprite Animation

    This is a question for people who know alot about animation or who have made games using sprite animation. What is the recommended number of frames for each different animation that the character does? I know some will take more than others like combo attacks, etc but overall for example lets say just walking, how many frames are recommended for something as simple as that?
  8. Loading Large Number of Files

    Ok, im creating a street fighter type game right now, im using characters from other games as my fighters. I got the sprite rips and for just 1 character, its 1,333 .png files. Is there a way I should load them that can make it less CPU intensive? Im programming this in C++ and SFML.
  9. 2D Arcade Fighter Game

    Thanks I will look into it.
  10. 2D Arcade Fighter Game

    Hello, can anyone give me any tips/hints on working out collision when making a Arcade Fighter? If you want specifics its going to be made using SFML and C++. Also, any programs that you would recommend to make the characters in? Any help would be appreciated.
  11. How can I make this cleaner...

    Yes it did. The language is C++ by the way. I will look more into it. Thanks
  12. Ok im making a Visual Novel and im starting to run into a problem. I wanna fix it before it gets worse lol. So the way I have been programming this is that every picture has a different number assigned to it. I have 3 switch statements, one for input, one for setting textures, and one for displaying. Is there a way to simplify this?  #include "Backgrounds.h" int menu_selector = 0; int main() { window.create(sf::VideoMode(1920,1080), "_______: The Beginning",sf::Style::Fullscreen); window.setKeyRepeatEnabled(false); window.setMouseCursorVisible(false); sf::Time time = sf::seconds(2); LoadFile(); //Loading Images, etc sf::Text text1("Ryuuji : To think I ended up dying in a shitty place like this...", font, 50); //77 Characters text1.setPosition(100,720); sf::Text text2("One moment I'm going out with this cute girl and the nexy, I get stabbed in the chest with", font, 50); //77 Characters text2.setPosition(100,790); sf::Text text3("a spear. What to do now...just wait? Hmm, I wish I had more time to at least say goodbye", font, 50); //77 Characters text3.setPosition(100,860); sf::Text text4("to my family. I never even got my first pathetic can I be. I never even got to", font, 50); //77 Characters text4.setPosition(100,930); sf::Text text5("touch her boobs. I wonder if I can remember how she looked like. Let me try...", font, 50); //77 Characters text5.setPosition(100,1000); while (window.isOpen()) { sf::Event event; while (window.pollEvent(event)) { if (event.type == sf::Event::Closed) {window.close();} if (event.type == sf::Event::MouseMoved) { mousesprite.setPosition(event.mouseMove.x,event.mouseMove.y); } if (event.type == sf::Event::KeyPressed) { if(event.key.code == sf::Keyboard::Escape) {window.close();} switch(game_state) { ///////////////////////////////////////////////////////MainMenu case 0: if(event.key.code == sf::Keyboard::Up) { menu_selector--; if(menu_selector < 0) {menu_selector = 0;} } if(event.key.code == sf::Keyboard::Down) { menu_selector++; if(menu_selector > 3) {menu_selector = 3;} } if(event.key.code == sf::Keyboard::Return) { switch(menu_selector) { case 0: game_state = 3; //Introduction break; case 1: game_state = 1; //Load Screen break; case 2: game_state = 2; //Credits break; case 3: window.close(); break; default: break; } } break; /////////////////////////////////////Load Screen case 1: break; ////////////////////////////////////Credits case 2: break; ///////////////////////////////////Introduction case 3: if(event.key.code == sf::Keyboard::Return) { game_state = 4; } default: break; } } } ///////////////////////////////////////////////// switch(game_state) { case 0: //Main Menu BG.setTexture(_0); break; case 1: //Load Screen BG.setTexture(_1); break; case 2: //Credits BG.setTexture(_2); break; case 3: //Intro BG.setTexture(_3); break; case 4: //BG1 BG.setTexture(_4); break; default: break; } //window.clear(sf::Color(0,0,255)); window.draw(BG); if(game_state == 3) { window.draw(npc1); window.draw(textframe); window.draw(text1); window.draw(text2); window.draw(text3); window.draw(text4); window.draw(text5); } window.draw(mousesprite); window.display(); } return 0; } Any help would be appreciated
  13. SFML Visual Novel and Lua

    Hello, I have a few questions regarding the usage of SFML and Lua. I want to create a visual novel, using SFML but im confused with the loop of it. First off, I know there are programs like Novelty, etc that can do it for me but since im only making one novel, I wanna code it by hand. My questions regarding this:   How would I go about programming the loop for this? Would a bunch of nested switch statements work or is there a neater or simpler way? My plan was to have 3 variables; story_spot, image_spot, text_spot. These are just made up names by the way just wanted to use it as an example. As the user picks choices, it would update each to a different integer number which would then change the text, image, etc. I guess this goes along with my first question but is this how I should be looking at it? I have heard people using Lua for game programming, is it something I should be using for this, if so what parts exactly? Im still not completely clear on the entire concept and usage of Lua but from what I have heard its mainly used for NPC functions and dialogue. If it is used for situations like that, should I be looking into using it for my dialogue. My plan in terms of dialogue was to have different files for different parts of the story and when "text_spot" would switch, so would the .txt file that the program was reading from. Any help would be appreciated.
  14. For example lets say I want to create a Visual Novel. Im trying to figure out how I can create a proper game loop where, the story will progress. So far this is what I normally do when I want to create a "story". -Check what to draw(ill explain more) -Draw Scene -Input -Rest For checking what to draw, lets say I have Option 1 and Option 2, in a function, I would have a switch statement nested into another switch statement, in another, etc...and each switch statement would have choices 1-4 maybe, where it would draw a scene based on a number that was assigned to it under that switch statement, like this: You have choice 1 or 2... switch(choice) case 1: draw(asdf) switch(choice2) case 1: case 2: case 2: draw(zxcv) switch(choice2) case 1: case 2: I know that is definitely not how you do logic and input so I was wondering what you guys would do in a situation like this.
  15. How is the Game Development field?

    So I can still go into game development just with a computer science degree?