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 - TehKyle

Pages: [1]
1
General / Rotating -1 to bigger number
« on: May 25, 2011, 12:54:47 pm »
Quote from: "Disch"
Code: [Select]
if (Event.Key.Code == sf::Key::Z){
//                    TileSelect--;
                    TileSelect += 7 - 1;
                    TileSelect = TileSelect % 7;
                }

Thanks, I totally forgot about that. Your code was off by one though, I don't know why you added -1. I used const int MAX_TILE which contained 7 and now it works as intended.

2
General / Rotating -1 to bigger number
« on: May 25, 2011, 05:13:53 am »
Modulus operator works fine if you add up, but how do you deal with -1 going back to 7 without special case code line (if possible)

Code: [Select]
               if (Event.Key.Code == sf::Key::Z){
                    TileSelect--;
                    TileSelect = TileSelect % 7;
                }
                if (Event.Key.Code == sf::Key::X){
                    TileSelect++;
                    TileSelect = TileSelect % 7;
                }

3
General / Large double array of sprite
« on: May 22, 2011, 12:09:13 pm »
I get segment fault with this code
 sf::Sprite TileMapSprite[600][400];
and then load the image and display only the appropriate sprite based on camera location.

Is there better way to store multiple tile with position stored?

4
General / Trying to keep sprite from moving off of the screen.
« on: May 21, 2011, 10:43:36 am »
You have to contain within the 0,0 and the window width, window height

Code: [Select]
       //Set camera within the boundary
        if (CamX < 0)
            CamX = 0;
        if (CamX >= MapMaxX - SCREENX)
            CamX = MapMaxX - SCREENX;
        if (CamY < 0)
            CamY = 0;
        if (CamY >= MapMaxY - SCREENY)
            CamY = MapMaxY - SCREENY;

5
General / SFML CPU usage
« on: May 20, 2011, 02:53:54 am »
It is using high cpu because you didn't put any fps limit.
http://www.bit-tech.net/news/gaming/2010/08/03/starcraft-2-doesn-t-limit-framerates/1 should be relevant

You can easily fix this issue by putting this code
Game.SetFramerateLimit(60);

6
General / Global variable vs Pass by reference
« on: May 20, 2011, 02:49:55 am »
Is it better to have RenderWindow as global variable or send it as reference to the function?

Map.Draw(&AppWindow) looks wonky and wondering if there is better way to code

7
General / Slow down game without altering user experience
« on: March 13, 2011, 05:25:56 pm »
use RenderWindow GetInput function instead of Event KeyDown

8
General / Best way to program 8 directional movement?
« on: March 13, 2011, 05:18:49 pm »
I want to reduce speed on diagonal movement, but I don't know how do code it properly.

Also, how do you deal with Left + Right and Up + Down conflict?
If you code something like

if (L) xFlag= -1;
if (R) xFlag= 1;
if (U) yFlag= -1;
if (D) yFlag= 1;
Move (xFlag, yFlag, framespeed)

You have Right and Down overwriting Left and Up when you press them together.

Pages: [1]
anything