• Content count

  • Joined

  • Last visited

Community Reputation

455 Neutral

About proanim

  • Rank
  1. Politics in games' storyline

    @GeneralJist   You bring up a good point. What I had in mind is to pick one of problematic wars (meaning pick the one that looks very complex with many sides participating) and put a protagonist there. But the catch is that entire story is on the side that fights against US and NATO (these two go together it seems), but the protagonist is not doing actual fighting since he/she is a civilian. Now what I see as problematic is that propaganda bit, all games out there are very much 'US is a good guy' which is not really true if you use your brain, and is a form of propaganda against the nation that might play the game (remember: not trying to start a flame war here).   Since you would play as civilian that is on the 'enemy' side you would probably see much of the dialog that could be interpreted as anti-us/nato propaganda but it is only natural to root for your own side in every situation at least in some way. The war part in question would be either in progress or recently ended while protagonist goes around doing his thing. What I see as a big immovable obstacle with this is that no matter how the game and its story is executed if it could be shamed as anti-us propaganda game it can't sell anywhere. Stuff could be made even worse with internet/media backlash to such game.
  2. 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...  ).   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...  ). 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.
  3. floating sprite problem

    Do I must have two separate instances for this to work? Can I still make this work if I don't separate logic and rendering? I know it might not be recommended practice but, I don't want to make stuff overly complex.
  4. floating sprite problem

    I tried to do that by following this implementation, here: and it didn't help at all, whats worse it degraded the performance to the point of unusable.   This is what I used to get my delta time in my original post: #ifndef _TIMER_H_ #define _TIMER_H_ #include <ctime> // adapted from timer class found on internet (no real changes, just coding style) class TimerClass { public: void start(); // constructor void stop(); // de-constructor void getTimes(); // begin/end variables clock_t begin, end; // variable declarations used for time calculation double ticks, msec, sec, min; }; #endif //////////////////////////////////// #include "timer.h" void TimerClass::start() { begin = clock() * CLK_TCK; } void TimerClass::stop() { end = clock() * CLK_TCK; getTimes(); } void TimerClass::getTimes() { ticks = end - begin; // stop the timer, and calculate the time taken msec = ticks / 1000; //milliseconds from Begin to End sec = msec / 1000; //seconds from Begin to End min = sec / 60; //minutes from Begin to End } I reached the point of total confusion, and I don't know how to implement loop suggested above with my own. 
  5. floating sprite problem

    i need a level editor with multiple windows menu bar and stuff, along side of sfml rendering window
  6. floating sprite problem

    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:   And these are the screenshots what happens depending on which side i choose to move the camera: (if i move camera up-left) (if i move camera down) (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(); } }
  7. Crash with <unable to read memory> error

    Ok i fixed it, thank you. Turns out I can't access with -> instead I need to use (dot).    my code had the following: GameMap* Map; Map->CreateMap(5, 5); ... and a like.   now it MUST be GameMap Map; Map.CreateMap(5, 5); Why is this?
  8. 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.
  9. How to get correct coords of the sprite

    It may be difficult to explain so take a look at these two screenshots   This one is when mouse is outside of the region that is a square 96x96 and is positioned to render windows 0,0 (but I positioned camera differently and zoomed out, as i have shown in the code)     And this one is when the mouse is in the region, original one (that is the square region from 0,0 to 96,96), that is placed just under the 'file' menu, not the actual, top left grid tile.     What I wanted is to have marker tile like in second screenshot when I hover over the tile, regardless of camera settings. So, from there, I guess my problem is getting info on where the actual sprite is and its current size.
  10. 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(); } }
  11. I am looking to create 2D game (maybe RPG, maybe rogue-like, maybe both ), 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? 
  12. math problems

      Wouldn't this actually be more complicated? I would need to create regular greed and rotate it 45 degrees, and than additionally transform mouse coordinates. Seems interesting but I am not quite sure how I would handle data in this case. Would I save out all data as if it was square greed and transform it on run-time?
  13. math problems

    This is all completely 2D stuff. What I did is, I created grid using one sprite and simply placing it on calculated X and Y coordinates to form a grid.   I am looking into point in polygon stuff, but I am not sure how to do this yet. This is what I am testing with // triangle to test against sf::ConvexShape hex; hex.setPointCount(3); hex.setPoint(0, sf::Vector2f(0, 0)); hex.setPoint(1, sf::Vector2f(96, 0)); hex.setPoint(2, sf::Vector2f(0, 48)); // check coordinates if inside the triangle if(Mouse.x >= hex.getPoint(0).x && Mouse.y >= hex.getPoint(0).y) if(Mouse.x <= hex.getPoint(1).x && Mouse.y >= hex.getPoint(1).y) if(Mouse.x >= hex.getPoint(2).x && Mouse.y <= hex.getPoint(2).y) { diamond.setPosition(0, 0); // this is tile marker - it will highlight the tile mouse pointer hovers over } Something is off since I am still in rectangle calculation and not triangle. Am I on the right track?   EDIT: I found this - - looks close to the first reply, and this does answer my question. Thanks for help everyone.
  14. I am trying to implement accurate selection tool for my level editor that would be able to use both isometric tiles and isometric hexagons. with the same sprite dimensions. I am now focusing on getting regular isometric tile to work properly.   Below is the color coded isometric tile that i will be using (it will be transparent with only lines visible, this one is for explanation only). I want my program to register specific tile if the cursor is only in green area.     The sprite has dimensions of 192x96. How do I calculate if the mouse is only in green area? Since from what I find everything is based on rectangle logic, because I check X, and Y coordinates of the mouse.   From here I have something like   if(mouse.x > 0 && mouse.y < 48)   if(mouse.x < 96 && mouse.y < 48)     select tile   but these coordinates also catch stuff from red triangle area in top left.
  15. array incrementation

    I wanted to draw a grid with array of sprites. And I made it work with this code // loop over each sprite, setting their textures // grid for(int i = 0; i < 20; i++) { spr[i].setTexture(tex); spr[i].scale(sf::Vector2f(0.55f, 0.55f)); // 1st row if(i < 10) spr[i].setPosition(105.6f * i, y); // 2nd row if(i > 10 || i < 20) spr[i+10].setPosition(105.6f * i, y + 52.8f); // 3rd row //if(i > 20 || i < 30) // spr[i+20].setPosition(105.6f * i, y + 105.6f); } Now I want to optimize this code so I can use it more efficiently later. The code brakes if I set spr[i] instead of spr[i+10] in second if loop. Why is this? How can I continue through the array without +10 or whatever next to it?