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

Pages: [1]
1
General / Re: Window will closes automatically when idle
« on: June 26, 2013, 10:41:22 pm »
The program in .exe file is not automatically close, just on when run the program from the visual studio 2010 still close automatically..  Thanks anyway..

2
General / Re: Window will closes automatically when idle
« on: June 26, 2013, 10:18:56 pm »
while(App.isOpen())
{
   sf::Event currentEvent;
   initGraphics(App);

          while(App.pollEvent(currentEvent))
     {

               if (currentEvent.type == sf::Event::Closed && currentEvent.key.code == sf::Keyboard::Escape)
               {
           App.close();
                }
          }
 }

3
General / Window will closes automatically when idle
« on: June 26, 2013, 10:00:09 pm »
Hai, i have create the game using this library.. but, when i run the game and idle it about 15 seconds, it closes automatically, i already assigned that when the user press "Escape" then window close, otherwise it will stay open.. but, why the window will closes automatically? please help.

4
General / Destroy the application when it is not been use
« on: June 25, 2013, 04:27:46 pm »
Hai, i am new on SFML 2.0.. First of all, i want to explain how my program works: i already created the Snake and Ladder game, with welcome screen, graphics (where everything run in here) and end game, and change player button, when the user run the game, the welcome screen appeared and when the user press number 1, 2 or 3 it change the screen to graphics and added the player ball depends on what number that the user hit on the keyboard.. My Question is: Is the welcome screen just hide on behind graphics and not well removed (i think of it because i not declare any delete function that destroy the welcome screen, just linked it), how to remove the welcome screen while not being used? and how to appear it again while the game is still running and the player hit "change player" button?

Thanks for those who answered my question.. Good night

5
General / Re: Image doesn't show in the screen
« on: June 09, 2013, 06:37:55 pm »
okay sir.. i got it already.. thanks a bunch :)

6
General / Re: Image doesn't show in the screen
« on: June 09, 2013, 05:34:36 pm »
Hmm, question sir: how do you make a 10x10 grid with image inside it? i try it couple of times, but instead of grid, i got 10x10 tile based map.. Thanks for the post earlier, it helpful for me a lot.. I mean for the 10x10 grid, is like this:
"http://www.google.com.my/imgres?imgurl=http://mathsclass.net/mcdownloads/img_1cm_10x10_Grid_Black.png&imgrefurl=http://unzacolwork1984.blog.cz/1302&h=629&w=592&sz=4&tbnid=Rwa-b3sFxUNGLM:&tbnh=90&tbnw=85&prev=/search%3Fq%3D10x10%2Bgrid%26tbm%3Disch%26tbo%3Du&zoom=1&q=10x10+grid&usg=__FC03oPh69YZown4gGvYAQTAfIWw=&docid=4ot_ERnOXi3beM&sa=X&ei=GqG0UfKwIM7arAfh5YDoCg&sqi=2&ved=0CCsQ9QEwAA&dur=309"

and for the tile based map, is like this:
"http://geekanddad.files.wordpress.com/2010/06/screen-shot-2010-06-22-at-11-43-19-am2.png"

The different between tile based map that i created and the 10x10 grid that i want to create, is no line that separate each blocks, like 10x10 grid that i mention to you (through image)

7
General / Re: Image doesn't show in the screen
« on: June 09, 2013, 02:25:16 pm »
Thanks for the correction and the advices, sir "The Hatchet", it is very helpful to me.. And also i will use what are you recommend me to use (vector or array and loop with functions that i want to display on it).. Since i am newbie on c++, i wanted to make snake and ladder game, though i've created that game using programming language AS3.. Thanks again sir :)

8
General / Re: Image doesn't show in the screen
« on: June 09, 2013, 01:31:41 pm »
Thanks for the reply..

Here is my code:

#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <iostream>
#include <iomanip>
#include <vector>

#define StageWidth 800
#define StageHeight 600
#define BitsPerPixel 32

using namespace std;

int main()
{
   sf::RenderWindow App(sf::VideoMode(StageWidth, StageHeight, BitsPerPixel), "Game");

   App.setFramerateLimit(30);

   sf::Texture grassTexture;
   sf::Texture waterTexture;

   vector<sf::Sprite> grassSprites(10, sf::Sprite(grassTexture));
   vector<sf::Sprite> waterSprites(10, sf::Sprite(waterTexture));

   if (grassTexture.loadFromFile("Images/grass.png") == 0)
   {
      return 1;
   }

   if (waterTexture.loadFromFile("Images/water.png") == 0)
   {
      return 1;
   }

   while(App.isOpen())
   {
      App.clear(sf::Color::Black);
      sf::Event event;

      while(App.pollEvent(event))
      {
         if (event.type == sf::Event::Closed || event.key.code == sf::Keyboard::Escape)
         {
            App.close();
         }
      }

      for (int i = 0; i < grassSprites.size(); i++)
      {
         grassSprites.setTexture(grassTexture);
         grassSprites.setPosition(100 + (i * 50), 200);
         App.draw(grassSprites);
      }

      for (int j = 0; j < waterSprites.size(); j++)
      {
         waterSprites[j].setTexture(waterTexture);
         waterSprites[j].setPosition(200 + (j * 100), 300);
         App.draw(waterSprites[j]);
      }

      App.display();
   }

   return 0;
}

9
General / Image doesn't show in the screen
« on: June 09, 2013, 01:17:49 pm »
hai, i am having a problem, my image doesn't showed up after i use the vector.. i dont know what's wrong with this, i am newbie in c++ and also sfml 2.0.. can u guys help me out? the one that i got while i run the program is black screen only..

code will be uploaded as file..

Any helps would be helpful to me.. thanks

Pages: [1]