Jump to content

  • Log In with Google      Sign In   
  • Create Account

proanim

Member Since 16 Mar 2011
Offline Last Active Aug 31 2015 03:13 PM

Topics I've Started

Politics in games' storyline

28 August 2015 - 02:02 PM

I had a sudden flash of inspiration, and I came up with still very loose outline for the story-line of the game I would like to make at some point. Given that there is a crap ton of video games that have you play as some nameless/faceless military type (American mind you) going half across the world to deliver 'justice' (Battlefield 3 I am looking at you, you too Call of duty... dry.png ).

 

If there was a game where you are to play a man that goes to a war zone or area where war may have ended recently, as a non-combatant or someone who isn't related to military, to help someone there about something, but with dialog constantly bashing the enemy that could very well be NATO force just so no one in particular gets offended of the bat; would you give that game a benefit of the doubt? Even if political undertones and indication of the past are only hinted at the player? 

 

I was always of the opinion that there shouldn't be any political views imposed at the player that might just want to maw down enemies and not worry about things (kind of like doom style games, good times... biggrin.png ). Also I would like to point out that I am not trying to start a flame war or something like that I am looking for opinions of others at the subject of openly presenting, political views that might not be to the liking of NATO countries, which are almost entire video game market there is.


floating sprite problem

05 February 2015 - 11:00 AM

I have a sprite that is supposed to stay in place when I move the camera around the level, but when I try to move it my sprite floats out of position while camera is moving. How can I fix this? I tried to do 'fix your time step' thing but something tells me I am doing it the wrong way.

 

Here are the screenshots that I cropped out to illustrate the problem.

 

This one is the correct position when camera is not moving: https://dl.dropboxusercontent.com/u/118608180/correct_position.png

 

And these are the screenshots what happens depending on which side i choose to move the camera: 

https://dl.dropboxusercontent.com/u/118608180/incorrect_position_1.png (if i move camera up-left)

https://dl.dropboxusercontent.com/u/118608180/incorrect_position_2.png (if i move camera down)

https://dl.dropboxusercontent.com/u/118608180/incorrect_position_3.png (if i move camera right)

 

And here is a releveant portion of the code I used:

float dt = 0.0f;

// loop until a WM_QUIT message is received
msg.message = static_cast<UINT>(~WM_QUIT);
while(msg.message != WM_QUIT)
{
	sf::Event Event;

	if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
	{
		// Win32 part
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
	else // SFML part
	{
		// start frame clock
		timer.start();

		RenderView.clear(sf::Color(64, 64, 64));

		// check mouse position
		Mouse = sf::Mouse::getPosition(RenderView);

		// set camera move speed
		cam->SetCamSpeed(1);
		dt = timer.msec;

		while(RenderView.pollEvent(Event))
		{
			if(Event.type == sf::Event::KeyPressed)
			{
				if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) // move camera up
				{
					cam->CamOffsetY -= cam->CamSpeed * dt;
					StandardView.move(0.0f, -(cam->CamSpeed * dt));
				}
				if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) // move camera down
				{
					cam->CamOffsetY += cam->CamSpeed * dt;
					StandardView.move(0.0f, cam->CamSpeed * dt);
				}
				if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) // move camera left
				{
					cam->CamOffsetX -= cam->CamSpeed * dt;
					StandardView.move(-(cam->CamSpeed * dt), 0.0f);
				}
				if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) // move camera right
				{
					cam->CamOffsetX += cam->CamSpeed * dt;
					StandardView.move(cam->CamSpeed * dt, 0.0f);
				}
			}
		}

		// find map tile that has mouse cursor on it
		for(unsigned int i = 0; i < spr.size(); i++)
		{
			if(Mouse.x + cam->CamOffsetX > spr[i].getGlobalBounds().left &&
				Mouse.x + cam->CamOffsetX < spr[i].getGlobalBounds().left + spr[i].getGlobalBounds().width &&
				Mouse.y + cam->CamOffsetY > spr[i].getGlobalBounds().top &&
				Mouse.y + cam->CamOffsetY < spr[i].getGlobalBounds().top + spr[i].getGlobalBounds().height)
			{
				ValidMarker = 1;
				marker.setPosition(spr[i].getPosition().x, spr[i].getPosition().y);
				break;
			}
			else
				ValidMarker = 0;
		}

		for(unsigned int i = 0; i < spr.size(); i++)
			RenderView.draw(spr[i]); // draw grid sprites
		
		RenderView.setView(StandardView);
		if(ValidMarker == 1) // draw marker if mouse is hovering over tiles
			RenderView.draw(marker);
		RenderView.draw(CharacterPawn);
		RenderView.display();
		
		// stop frame clock
		timer.stop();
	}
}

Crash with <unable to read memory> error

30 November 2014 - 08:52 PM

I don't know how to fix this error that popped up when I tried to assign value of variable to another variable. Program crashes when I try to assign value of variable B to variable A, this thing should not happen, and I think I already tried everything. This is what I have:

class GameMap
{
public:
	GameMap();
	~GameMap();

	int SetMapSizeX(int SizeX);
	int SetMapSizeY(int SizeY);

	int GetMapSizeX();
	int GetMapSizeY();
	int GetMapSize();

	int MapSizeX;
	int MapSizeY;
	int MapTotalSize;
};

GameMap::GameMap()
{
	MapSizeX = 0;
	MapSizeY = 0;
	MapTotalSize = 0;
}

GameMap::~GameMap()
{
}

int GameMap::SetMapSizeX(int SizeX)
{
	return MapSizeX = SizeX;
}

int GameMap::SetMapSizeY(int SizeY)
{
	return MapSizeY = SizeY;
}

int GameMap::GetMapSizeX()
{
	return  MapSizeX;
}

int GameMap::GetMapSizeY()
{
	return MapSizeY;
}

int GameMap::GetMapSize()
{
	GetMapSizeX();
	GetMapSizeY();

	return MapTotalSize = MapSizeX + MapSizeY;
}

Code maybe looks bad but it, had to separate everything so I can findout what exactly caused this error.

So, the crash is on this line:

return MapSizeX = SizeX;

I am not sure what am I doing wrong here.


How to get correct coords of the sprite

30 October 2014 - 09:30 PM

I am having real trouble with making my program highlight correct tile on the grid when I hover over with the mouse (over the tile on the grid). I have my grid drawing correctly and my marker tile is working, but when I so much as move the camera, coordinates don't get updated for the tiles on the grid when I do sprite.getGlobalBounds() part.

 

I am not sure what am I doing wrong, here is the relevant code

// create an array of 100 sprites for 10x10 grid
	sf::Sprite spr[100];
	// x and y coordinates for grid tile placement
	float x = 0.0f;
	float y = 0.0f;

	// create 10x10 grid
	for(int i = 0; i < 100; i++)
	{
		spr[i].setTexture(tex);
		// scale sprite using formula -> target size / original size for both x and y
		//spr[i].setScale(sf::Vector2f(48.0f / spr[i].getLocalBounds().width, 48.0f / spr[i].getLocalBounds().height));
		
		if(i < 100)
			spr[i].setPosition(96.0f * (i % 10), y + (96.0f * (i / 10)));
	}

	// create tile marker
	sf::Sprite marker;
	marker.setTexture(tex);
	marker.setColor(sf::Color(255, 0, 0));
	marker.setPosition(-96.0f, -96.0f);

	// store mouse position
	sf::Vector2i Mouse;

	// create a view with the rectangular area of the 2D world to show
	sf::View view;
	view.setSize(800.0f, 600.0f);
	view.setCenter(sf::Vector2f(400.0f, 300.0f));
	view.zoom(2.0f);
	SFMLView.setView(view);

	// loop until a WM_QUIT message is received
	msg.message = static_cast<UINT>(~WM_QUIT);
	while(msg.message != WM_QUIT)
	{
		if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			// Win32 part
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		else // SFML part
		{
			SFMLView.clear(sf::Color(64, 64, 64));

			for(int i = 0; i < 100; i++)
				SFMLView.draw(spr[i]); // draw grid sprite

			// check mouse position
			Mouse = sf::Mouse::getPosition(SFMLView);

			if(Mouse.x > spr[0].getGlobalBounds().left && 
				Mouse.x < (spr[0].getGlobalBounds().left + spr[0].getGlobalBounds().width) && 
				Mouse.y > spr[0].getGlobalBounds().top && 
				Mouse.y < (spr[0].getGlobalBounds().top + spr[0].getGlobalBounds().height))
			{
					marker.setPosition(0.0f, 0.0f);
			}
			else
				marker.setPosition(-96.0f, -96.0f);

			SFMLView.draw(marker);
			SFMLView.display();
		}
	}

storing level data

19 August 2014 - 02:30 PM

I am looking to create 2D game (maybe RPG, maybe rogue-like, maybe both biggrin.png), but i am facing a problem coming up with a solution for storing level data. I want to create initial level structure through tile system, but I don't want game it self to be dependent on tiles.

 

All levels can be created with tiles, that is tiles for ground, walls and other stuff, but than I would like player and other characters to be moving in freely without being constrained tiles and have fallout type zig-zaging and such. What confuses me is the fact that tiles that were used to construct the level would be written in a file in a way that would make sense to a human.

 

How should i go around storing data for a character's position if its not constrained to tiles? 


PARTNERS