Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Vot1_Bear

Pages: [1]
1
Graphics / Best way to render, performance-wise
« on: September 25, 2013, 10:28:01 am »
Hello again SFML community!

I am currently developing a game project, and it has come to my attention that the performance is quite lacking, at least for me and some of my testers.

One of my biggest concerns is the rendering method I use. Performance-wise, what is the most efficient way of rendering sprites to the window?

Currently I am using a RenderWindow and its draw() function to draw sprites on it, then use display() at the end of every loop. Some post on the internet suggested using a RenderTexture first, however, and only extracting it to a Texture and drawing it to the Window in the end of the loop.

1. So which one of these are better, and if neither of them are, is there a faster way to render sprites?

2. Will maintaining a "background" RenderTexture (a texture that won't change and can be reused over and over again) give significant improvement than rendering ~100 sprites to the RenderWindow per loop?

3. Which process is actually the most expensive one anyway? The draw(), or the display() function?

4. On an unrelated (window-related) note, what does setVerticalSyncEnabled() do? Can it be used together with setFrameRateLimit()?

For reference, the target FPS is about 30. There are occasionally some lag during gameplay on my laptop, but considering how it can run skyrim pretty fine (at low specs though), I kinda doubt the code logic is the source of the problem. Or can you actually 'request' more performance priority from the machine?

Thanks!

2
General / Implementing online play to a game
« on: September 22, 2013, 10:00:27 am »
Hello again everybody!

As the title might imply, currently I'm thinking of implementing networking to my game Blastorium. However, having zero experience with networking, I need to ask a question or two...

(For those who are not familiar with the game I'm developing, It's a bomberman-esque game (meaning it's real-time). I figured this info would be necessary)

  • At a target of 30FPS, How much and what kind of data can/should I send?
    Should have both player calculate the logics themselves and only send the commands used by another player (Risk of missing some packets and making both players lose sync)?
    Should I instead just send the important informations (Player position, HP, and weapon usage) and let each machine handle commands themselves?
    Both of the above?
    Or should I have one server who receives commands of client players, calculates logic and sends the important information (Position, HP, etc) in return?

    I still have zero idea on how much I can send/receive with a reasonable enough connection, so please help

  • Which socket type?
    Reading the tutorial UDP seems to be a good idea here (speed), but any expert insight on this?

  • How do I connect two separate players through the net?
    Do I have them each send their IP adresses to each other prior to play? Or host an online server which catalogues online IPs and matches up players with each other? If the latter is possible, how (What kind of online server do I need to use, etc)?

And as a disclaimer, I suck at am still learning C++, using competitive programming as a base. I understand the basics and algorithms like dijkstra or segment tree or something but still have zero idea on class inheritances and stuff. Thus, I'd like to apologize beforehand if some of these questions have trivial answers or you have troubles explaining something to me... But I'll do my best to learn.

Thanks in advance!

(I'm still unsure whether this belongs in general or networking subforum. I'm asking about implementing networking, but I feel like some of the questions refer more to general topics instead of the actual networking module)

3
General / Help - Random heap corruptions.
« on: September 10, 2013, 01:04:28 pm »
Hello SFML Community!
This question is a bit long, so I'll try to summarize it first as briefly as possible.

I'm having problem with my game project, Blastorium.

It runs finely on my machine, but will randomly stop working (went not responding) in other machines. I'm using Windows 7, but the errors show no consistency on OS or specs. The most likely cause is heap corruption, as I did suffer from it some time ago (but it was solved on my machine).

My project's github can be found here, but as a disclaimer, I am an extreme beginner in C++ with nothing much of a guide on coding a program, so the code you're going to see is downright horribly untidy and unstructured.

Since I suspect scanning through all the files won't be feasible for most of you, here's the pseudocode:
Quote
Files used:
-Main.cpp (main)
-Interface.cpp (runs functions such as transition screens and main menu screen)
-Select.h/cpp (class, runs the select screen, that is, the part where you select weapons/stage)
-Tilelist and Texturemanager.h/cpp (class, manages sprites/textures and rendering individual sprites)
-Globals.h/cpp (class, contains a shared_ptr<> of all the classes below as for global access)
-Engine.h/cpp (class, the main game loop runs here. Calls most of other classes below)
-Player, Level, Powerups, WeaponManager, WpnBomb/Mine/Rocket/Medi .cpp/h (classes, maintains the aspects of the game such as players/powerups/etc, and also runs their Logic() and Render() functions every loop)
Each class below Engine.cpp has their own tilemanager and texturemanager, meaning they load files themselves and handles their own logic and rendering. Engine.cpp only calls them

Every class with the exception of main menu GUI classes (SelectManager) and utility classes (TileList, TileManager) is handled by GlobalManager class.
The GlobalManager class contains a shared_ptr<> to each of those classes, and each is initialized immediately once the app was run. Later on in the game. Engine.h will fill each of those classes with the necessary information based on user inputs (Which map, which weapons, etc). This is re-done every game loop, e.g. from start to game over.

Pseudocode of what's happening when you run it
  • Run Main.cpp
  • Main.cpp initializes Engine class, SelectManager class (select screen) and GlobalManager class
  • Main.cpp calls MainMenu function (not a class) from Interface.cpp
  • MainMenu() draws all the gears and receive input, returning an int
  • If it signals a play command, main menu runs the SelectScreen function from SelectManager
  • SelectScreen function receives input and returns accordingly
  • Main.cpp runs the Go function of the Engine class, initiating the game
  • Engine.cpp initializes every other class for a game round (levels, player, weapons, etc)
  • Each respective classes loads their own files
  • In each game loop, Engine calls the Logic and Render function of each class
  • If a player's HP reaches zero, Engine calls the FinishMatch function of Data class
  • Data class prints numbers then returns
  • Engine then calls the EndGameChoice function (not from a class), which receives user input
  • -If it selects play again, engine refreshes every class and runs again
    -If it selects main menu, engine stops and the program returns to Main.cpp, to no.3 to be precise
    -If it selects exit then the game exits accordingly

Heap corruptions commonly happens when you close the game (The last step, when you press exit) but in rare cases, during the initialization of the game after select screen (step no.7-9)

Do note that in previous versions, there were no select or main screens (meaning the program skips steps no. 3 to 6) and the game runs just fine. Perhaps that holds some relevance.

Anything that might help would be appreciated. As of now, I still hold very little knowledge on good/bad programming habits, or tracing the source of these errors, and programming in general.

I know that my coding is horrible and that the problem most likely stems from an incorrect structure of the program itself, but I really need help with it.. Most tutorials on the internet only covers the basics of a single file and not how they are supposed to work together, and I'm out of ideas on how to fix the problem (especially since it runs fine on my machine, making debugging difficult).

Another question, though not as pressing, is performance. Is there a reason why my game still somewhat lags at 30FPS even on machines that runs 3d games just fine? I'm pretty sure my code is not that horrible (or maybe it is) to cause such drop in performance

Thanks in advance, and sorry if the question is too much or lacking information.

4
General / Relation between sf::keyboard::key and char
« on: August 17, 2013, 09:19:14 am »
Hello SFML community!

I was wondering about implementing customizable controls for a game I'm currently working on, and this question somewhat popped up on my mind: Is there any way we can convert an sf::keyboard::key (say, A) into its char/string name counterpart?

In order to create an actual options/controls screen, I'd need to be able to convert a sf::keyboard::key into a string of what it represents, which will be shown to the screen. Currently though, the only thing I can think of is manually represent each code as a specific char or string (using a ton of ifs to assign sf::keyboard::key::A into "A", sf::keyboard::key::Lshift into "Left Shift", etc).

I'm pretty sure i'm not the first to face this problem, so is there a better alternative to this?

Thanks in advance :)

5
Hello SFML community! Welcome to the thread showcasing my little study experiment...


Older versions:
-v1.2.1 beta
-v1.1.0 beta

The idea is basically a bomberman-esque game with more than bombs in your arsenal. Currently there are only 4 weapons into the game, but I plan to add more weapons to the game with varying but balanced strength and weaknesses, hoping that it'd make every game experience a unique one and that it'll add some additional depth to the already great idea of bomberman.


Future plans would be adding more weapons, sounds, and easier access to the game via tutorial pages. A possible extension in the long term, however, is a single-player mode since a multiplayer game that's limited to a single machine can be quite unenticing to play. Or perhaps networking, but that's pretty much still too advanced  for my skill level.

Most of the resources are either self-made or under creative commons license... I think. Developed  by myself using Microsoft Visual C++ express 2010 with rapidxml and SFML 2.0. 

Hope you guys enjoy it!

Pages: [1]