Exemplo n.º 1
0
int main(int argc, char ** argv)
{

    Screen s;
    Events ev(&(s.GetInput()), argv[1]);
    sf::Event real;
    Client myClient(argv[1], s.GetStruct());
    myClient.Launch();
    while(s.IsOpened()){
        if(myClient.MGetPointeurPartieEncours()){
        while(s.GetEvent(real)){
            if (real.Type == sf::Event::Closed){
                s.Close();
                myClient.Terminate();
            }
        }
        ev.Try(s.GetFrameTime());
        s.Refresh(s.GetStruct());
        s.Display();
        }
    }
    return 0;
}
Exemplo n.º 2
0
int MainProgram()
{
	Screen screen;

	if (screen.Init(0xFFFF00FF) == false)
	{
		std::cout << "Init went wrong" << endl;
		return 1;
	}

	int playerWidth, playerHeight, bulletWidth, bulletHeight;
	Uint32 *imageData = ReadBmp("P:\\My Documents\\Visual Studio 2013\\Projects\\SDLGame\\Debug\\firefox.bmp", playerWidth, playerHeight);
	Uint32 *bulletImage = ReadBmp("P:\\My Documents\\Visual Studio 2013\\Projects\\SDLGame\\Debug\\AimReticle3.bmp", bulletWidth, bulletHeight);
	int elapsed;
	
	float position[2] = { 0, 0 };
	{
		float bulletPos[2] = { 0, 0 };
		float bulletSize[2] = { bulletWidth, bulletHeight };
		Bullet bullet(bulletPos, bulletImage, );

	}

	while (true)
	{
		
		const Uint8* newKeyboardState = SDL_GetKeyboardState(NULL);
		
		if (screen.ProcessEvents() == false)
			break;

		ProcessKeyboard(newKeyboardState, screen);
		elapsed = SDL_GetTicks();

		for (int y = 0; y < screen.SCREEN_HEIGHT; ++y)
		{
			for (int x = 0; x < screen.SCREEN_WIDTH; ++x)
			{
				//screen.SetPixel(x, y, (sin(elapsed / 1000.0) + 1) * 127, sin(((elapsed / 1000.0 + 50) * 2) + 1) * 127, sin(((elapsed / 1000.0 + 120) * 3) + 1) * 127);
			}
		}

		if (imageData == nullptr)
			break;

		position[0] += velocity[0];
		position[1] += velocity[1];

		if (position[1] < 0)
		{
			position[1] = 0;
		}
		else if (position[1] + playerHeight > screen.SCREEN_HEIGHT)
		{
			position[1] = (float)(screen.SCREEN_HEIGHT - playerHeight);
		}
		if (position[0] < 0)
		{
			position[0] = 0;
		}
		else if (position[0] + playerWidth > screen.SCREEN_WIDTH)
		{
			position[0] = (float)(screen.SCREEN_WIDTH - playerWidth);
		}

		for (int y = 0; y < playerHeight; ++y)
		{
			for (int x = 0; x < playerWidth; ++x)
			{
				screen.SetPixel(x + (int)position[0], y + (int)position[1], imageData[(y * playerWidth) + x]);
			}
		}

		screen.Update();
	}
	delete[] imageData;
	screen.Close();
	return 0;
}