Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


lride

Member Since 16 Aug 2012
Offline Last Active Yesterday, 09:39 PM

Topics I've Started

Trying to write my own GUI with SFML

Yesterday, 08:00 PM

Hello, I'm trying to write my own GUI system with SFML, but I'm a bit lost where to start...

Like how should the classes be designed? How should the events be handled when there are  2 overlapping windows? 

Are there any resources on this?


passing variadic arguments

04 March 2015 - 06:05 PM

struct A
{
	A(){}
	A(int i, std::string s){}
	A(std::string  s){}
};

A createA(...)
{
	return A(...);

}

int main()
{
        createA();
	createA(1, "zz");
	createA("zz");
}

I'm getting error C2143: syntax error : missing ')' before '...'

why??

Am I doing the interpolation correctly?

28 December 2013 - 11:31 PM

I'm trying to implement network entity interpolation described in this article: http://www.gabrielgambetta.com/fpm3.html

 

so far I have this and the circle's movement looks jittery. What did I do wrong?

struct Circle
{
	sf::Vector2f current;
	sf::Vector2f last;
	sf::CircleShape shape;
	Circle()
	{
		shape.setRadius(100);
	}
	void interpolate()
	{
		sf::Vector2f difference = current - last;
		current.x += difference.x * 0.1;
		current.y += difference.y * 0.1;
	}
	void draw(sf::RenderWindow & window)
	{
		shape.setPosition(current.x, current.y);
		window.draw(shape);
	}
	void setPosition(sf::Vector2f v)
	{
		last = current;
		current = v;
	}
};

//server 
void server()
{
	sf::TcpListener listener;
	sf::TcpSocket client;

	listener.listen(PORT);
	listener.accept(client);
	client.setBlocking(false);


	Circle circle;
	sf::RenderWindow window(sf::VideoMode(800, 600), "server");

	sf::Clock clock;
	sf::Time elapsed = sf::Time::Zero;
	sf::Time timePerFrame = sf::seconds(1 / 20.f);

	while (window.isOpen())
	{
		sf::Time dt = clock.restart();
		elapsed += dt;
		while (elapsed > timePerFrame)
		{
			elapsed -= timePerFrame;
			sf::Event event;
			while (window.pollEvent(event))
			{
				if (event.type == sf::Event::Closed)
					window.close();
			}

			sf::Packet packet;
			sf::Socket::Status s = client.receive(packet);
			while (s == sf::Socket::Done)
			{
				//new position sent from the client;
				float x, y;
				packet >> x >> y;
				circle.setPosition({ x, y });
				packet.clear();
				s = client.receive(packet);
			}
			circle.interpolate();
		}

		window.clear();
		circle.draw(window);
		window.display();
	}
}

what's wrong with my code?

 


memory leak dectector for vs 2013

21 December 2013 - 11:44 PM

What's a good memory leak detector for VS 2013?


java applet flickering

12 June 2013 - 11:20 AM

import java.applet.*;
import java.awt.*;

public class Game extends Applet implements Runnable
{
	Thread th;
	public void start()
	{
		th=new Thread(this);
		th.start();
	}
	public void run()
	{
		while(true)
		{
			try{
				repaint();
				th.sleep(0);
			}catch(Exception e)
			{
				e.printStackTrace();
			}
		}
	}
	public void paint(Graphics g)
	{
		Dimension d=getSize();
		g.fillRect(0, 0, d.width, d.height);
		g.setColor(Color.green);
		g.drawLine(0,  0,  100,  100);
	}
}

The applet flickers a lot so it's very disturbing.

Is there something I'm doing wrong?


PARTNERS