Jump to content

  • Log In with Google      Sign In   
  • Create Account


0026sd

Member Since 20 Sep 2012
Offline Last Active Aug 09 2013 11:05 AM
-----

Topics I've Started

Changing a Character's Armor or Appearance

07 August 2013 - 07:29 AM

Hi everyone!

 

Simple question: I'm wondering how to handle armor or appearance upgrades in-game specifically relating to the sprite's appearance. Say the player gets a new helmet! How do I reflect that on the character? What if I have 50+ different combinations of armor/clothing for each type of character in the game? Would I need to have a separate sprite image for each combination? Or does the character sprite have a base model and you overlay images onto that? What about animation for shirts or pants or weapons... Gosh, this seems quite overwhelming.

 

Anyway, hopefully I've gotten my question across in an understandable way. I'm sure that there's an easy solution for this but I can't imagine what that might be.

 

Thanks for any advice or help!

Scott.


SFML Frame Per Second feedback

31 October 2012 - 07:38 AM

Hi everyone,

I wanted to add an FPS visual in my game so I converted a script I saw in the XNA 3.0 book to SFML. I'm bascially just wondering if there's any way to optimize the performance as it sometimes eats up more CPU than I would have thought it should. Here's the code:

Main.cpp
[source lang="cpp"]#include <SFML/Graphics.hpp>#include <iostream>#include "FPS.h"#define ScreenWidth 500#define ScreenHeight 300int main(){ sf::RenderWindow window(sf::VideoMode(ScreenWidth, ScreenHeight, 32), "SFML Template"); window.SetFramerateLimit(200); FPS fps; fps.Initialize(); while(window.IsOpened()) { sf::Event Event; while(window.GetEvent(Event)) { if(Event.Type == sf::Event::Closed || Event.Key.Code == sf::Key::Escape) window.Close(); } window.Clear(); // Draw Game Components fps.Draw(window, (ScreenWidth / 2) - 25); window.Display(); } return 0;}[/source]

FPS.h
[source lang="cpp"]#pragma once#include <SFML/Graphics.hpp>#include <iostream>#include <sstream>class FPS{private:float fps;float updateInterval;float timeSinceLastUpdate;float frameCount;sf::String string;std::stringstream ss;public:FPS(void);~FPS(void);void Initialize();void Update(sf::RenderWindow &window);void Draw(sf::RenderWindow &window, float cameraX);};[/source]
FPS.cpp
[source lang="cpp"]#include "FPS.h"FPS::FPS(void){}FPS::~FPS(void){}void FPS::Initialize(){float updateInterval = 1.0f;float timeSinceLastUpdate = 0.0f;float frameCount = 0.0f;string.SetSize(12);string.SetColor(sf::Color::White);}void FPS::Update(sf::RenderWindow &window){}void FPS::Draw(sf::RenderWindow &window, float cameraX){frameCount++;timeSinceLastUpdate = window.GetFrameTime();if(timeSinceLastUpdate > updateInterval){ fps = frameCount / timeSinceLastUpdate; ss << "FPS: " << fps; string.SetText(ss.str()); string.SetPosition(cameraX, 20); window.Draw(string); ss.str(""); frameCount = 0; timeSinceLastUpdate -= updateInterval;}}[/source]

Games with menus

20 September 2012 - 12:03 PM

Hi everyone,

Just a general question. Are game menus (Start menu, pause menu, etc) typically put into their own class where all the drawing and logic would take place or are the menus all programmed in the main game logic class?

A lot of the tutorials and books I'm reading all have the start menu in the main game class however these are very simple menus (An image that says press enter to start game). I want to make complex menus with character stat selection and pause menus with options. Surely menus with so much logic wouldn't all be crammed into the main game class...?

Thanks,
Scott

PARTNERS