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.


Messages - nicox11

Pages: 1 [2] 3
16
General / Re: Sprites inside a Class
« on: April 11, 2016, 05:07:55 pm »
mapPlayers() is not a constructor. Sorry, but you seem to not know what you are doing. I recommand you to read a complete C++ tutorial before trying to play with SFML (and not only some parts). SFML need basics knowledge about C++ programming that it appears you don't have. The problem here is not really SFML related, but instead syntaxic C++ programming.

For your problem, there is multiples solutions. Basicly, you can keep an instance of your texture by adding it as private member of your class. Use something like a ressource manager or even other methods.

If you are convienced you have enough skills, I recommand you to seek for SFML book, and check for the online tutorial the official website provides.

17
General / Re: Exception Thrown when trying to run program
« on: April 11, 2016, 04:31:45 pm »
 if (z == 1) {
    img.setPixel(x, y, sf::Color::Black);
}
else {                                
    img.setPixel(x, y, sf::Color::Black);
}

what's the difference here ? You either way define black as the pixel color.

18
General / Re: Sprites inside a Class
« on: April 11, 2016, 04:24:17 pm »
Quote
the first result that i had was a blank white rectangle. please help

In your code :

sf::Sprite sprite(){
         sf::Texture texture;
            texture.loadFromFile("gunship.png");
            texture.setSmooth(true);
        sf::Sprite playersprite;
        playersprite.setTexture(texture);
        return playersprite;        
}

You create the texture in the sprite() function, but once it reaches the end of the function, the texture is free. When you want to display your sprite later, the texture is not in memory anymore, leading to a blank square. You need to keep track of your texture untill the destruction (or the use) of your sprite.

More informations http://www.sfml-dev.org/faq.php#graphics-white-rect


Please, be careful when you create code. You do not define you default construtor, but you implement it in your cpp file. However, you implement your sprite function in the header whereas you should implement it in the cpp. It seems like a lack of basic coding competencies, you should maybe go back to the basics.

19
System / Re: sf::Vector comparison operator (< and >)
« on: April 11, 2016, 01:41:35 pm »
Operator need no space between operator and < so change it this way :

operator<

20
Network / Re: Non-blocking usage and Status handling
« on: April 11, 2016, 10:32:55 am »
Question #1:
It depends on your architecture. But, I think you could simply gather the data you have to send and send them directly. If you want to send data at a single rate, maybe a queue can do the job.

Question #2:
If a client gets disconnected at the time you are sending a packet, I don't see any reason the send method wouldn't return sf::Socket::Disconnected. You can implement a timeout system, in order to detect users that suddenly can't reach the server (disconnected).

Question #3:
I'd simply build a fixed time rate loop that sends, let's say 30 times per seconds, the actual state of the game to the clients. I'll not bother if the client is ready or not, receiving or not. But, at the same time, i'd implement a time out system to detect clients that are not receiving or sending by removing them.

Question #4:
Same as #3

21
Window / Re: Get User's Resolution
« on: April 08, 2016, 11:47:24 am »
Show us your code, this look like simplistics syntaxes more than the lines you shown.

22
General / Re: How to make a bullet curve
« on: April 05, 2016, 02:21:20 pm »
Since your question is vague, you can simply search for vague answer. You should look for gravity implementation in 2D games.

If you have existing code, it may be useful to show it to us to help you implementing your bullet physic.

23
Network / Re: My generic questions about network
« on: April 04, 2016, 05:51:36 pm »
Ok, you convinced me about the importance of a central server.
What I want to do is exactly what a game like Hearthstone does.
- It is a 1v1 turn-based strategy game, the player only needs to communicate with his adversary.
- There's no lobby, the match-making is a black box.
- The data transferred is not time critical, which is why I'm using TCP/IP.
- The data transferred is very small.

So how exactly does a server like this work? This is how I imagine:
- Player connects to server.
- Server matches 2 players together.
- Players start match.
- Whenever a player has some information to send to the other player, it says to the server: "Hey, I don't know who am I playing with (his IP Adress), but whoever it is, could you please send this to him?"
- Server says: "Sure buddy! Let me just check if you are cheating."

Is that right?

And also, considering the complexity of the calculations performed by this server in this scenario, and considering that the game is moderately successful (meaning there will be thousands of games happening in any given time) is renting a machine recommended? Or is there another solution?

Thanks!

That's how I'd do it.

You have to find what will cost the most (in term of CPU). Checking for cheating ? (it seams no like a big deals since you say "The data transferred is very small" even if it doesn't necesseraly means it's easy) Pairing player ? Anyway, thousands of games happening, i don't see how you can handle this without a dedicated machine. Wait for experienced network developper, since I never made a game of this size.

24
Network / Re: My generic questions about network
« on: April 04, 2016, 05:08:12 pm »
Question 4 : I see some problem with your idea. I don't think player should be able to know their IP address and connect directly. This can lead to severe problems, especialy in an anonymous center. Instead, player shoudl always connect to the server, and then the server send back the data to the other player (allowing you to check for the validity of the data before sending it if you want, proventing your application from cheating systems). You can check the documentation of selector since it will surely do want you want.
I understand the cheating possibility. But here is what I'm most concerned about: money. I don't even know if that's a big deal or not, I'm just trying to foresee my future, but if I make so that all the data being transferred within the players passes through a server to be processed first, I would need the server to be running in a better machine with a better internet connection, right? But if I have the server acting only as a hub where the match-making happens, I can run the server in a much cheaper machine.

Also, as far as I know, cheating will always be a possibility if the cheater is brave enough.

Thoughts?

Of course cheating will always be a possibility, but it'll be way harder with a central server. I told about cheating, but it's not the only problem. Letting player know about adversary IP address can leads to hacking issue (which is bad for your reputation). About the price, of course it costs more to launch a dedicated server for all player, but the server can simply act as a relay (just to not let player know adversary IP, and add simplistic cheating provention system that do not need a lot of cpu). What will be your requierements ? How many players will play at the same time ? A solution is to permit player to launch a server (so giving the "central server program").
Anyway, you can only make a hub server as you said, but take in consideration that it is maybe not the best (or maybe is ! But i don't see many negatives points launching a "central server").

25
Network / Re: My generic questions about network
« on: April 04, 2016, 10:50:14 am »
Question 1 : I don't think there is any problem with this (you should maybe wait for a more experienced response).

Question 2 : Why don't you test it yourself ? :)

Question 3 : Check your firewall, this is surely the problem. Take in account that you need to open the specified port into your router if it has a firewall function. Make sure to use your public IP address (since you said you were beginner, we never know :) ).

Question 4 : I see some problem with your idea. I don't think player should be able to know their IP address and connect directly. This can lead to severe problems, especialy in an anonymous center. Instead, player shoudl always connect to the server, and then the server send back the data to the other player (allowing you to check for the validity of the data before sending it if you want, proventing your application from cheating systems). You can check the documentation of selector since it will surely do want you want.

26
General / Re: Why isn't the image being displayed?
« on: April 01, 2016, 04:40:51 pm »
The first thing you should do is to check for the return value when you are loading the texture. Then, check for your directory. I'm pretty sure you developpement tool create separate folder for release and debug, meaning that the link to the image should be "../Images/catz.png".

27
General discussions / Re: Keyboard array?
« on: March 25, 2016, 09:46:07 am »
Can't you simply use sf::Keyboard::isKeyPressed ? (I surely don't understand your needs).

http://www.sfml-dev.org/documentation/2.3.2/classsf_1_1Keyboard.php

28
General / Re: Project_battleship: question about events
« on: March 24, 2016, 10:25:59 am »
Here is an idea of mine (maybe not the best) :

Use like a kind of cyclic container :
http://stackoverflow.com/questions/1863597/c-scrolling-through-items-in-an-stlmap

Everytime a key is pressed, you store it with the time in the "cyclic" container. You then have to check every frame if combo of key is pressed in the right order within a timerange (ie: if the combo is right but took too long, don't register it as right combo).

I don't know if it's clear. But you should find something seeking for fighting game combo programming.

29
Interesting book. It is good for theory that the last book didn't cover like the Entity Component System, the Event and Messages delivery between system and the network. But, the implementation is quite huge and really hard to follow, it would be much better focusing on detailed examples instead of a full compilable project (that's my opinion).

On the other hand, it seams less modern than the previous book, not always using modern feature (Still raw pointer, i don't really know why). For example the tilemapping system doesn't use vertex, but even the Laurent's tutorial demonstrate how to gain perfomance with it.

To conclude, it's for me a great book to go further after the previous one and try to elaborate greater architectures, but only try to follow the architecture instead of the code presented.

30
General / Re: Installing TMX Loader
« on: March 03, 2016, 01:36:27 pm »
It did the trick, thank you.

I've followed the wiki and now I don't really know how to link it to my project. Here is my current makefile :

program_NAME := arena


program_C_SRCS := $(wildcard *.c)

program_CXX_SRCS := $(wildcard *.cpp)

program_C_OBJS := ${program_C_SRCS:.c=.o}

program_CXX_OBJS := ${program_CXX_SRCS:.cpp=.o}

program_OBJS := $(program_CXX_OBJS) $(program_C_OBJS)

program_INCLUDE_DIRS :=

program_LIBRARY_DIRS :=

program_LIBRARIES :=

CPPFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir)) -std=c++11

LDFLAGS += $(foreach library,$(program_LIBRARY_DIRS),-L$(librarydir))

LDFLAGS += $(foreach library,$(program_LIBRARIES),-l$(library))

SFML = -lsfml-graphics-d -lsfml-window-d -lsfml-system-d

.PHONY: all clean distclean

all: $(program_NAME)

$(program_NAME): $(program_OBJS)
        $(LINK.cc) $(program_OBJS) -o $(program_NAME) $(SFML)

clean:
        @- $(RM) $(program_NAME)
        @- $(RM) $(program_OBJS)

distclean: clean

 

Thank you

Pages: 1 [2] 3