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.


Topics - noaboa

Pages: [1]
1
General / Rotate against sprite
« on: March 21, 2016, 07:49:22 pm »
Hi, I am trying to make a tower defence game. I have made the map, which loads files so I don't have to rewrite everything, an enemy that moves within the path, and bullets. Since I am making a tower defence game, I think I should rotate the tower against the enemy. What is the algorithm, or how should I do it?

2
General / C++ Lua scripting tutorial
« on: February 01, 2016, 05:24:41 pm »
Hi, I did not know where to put this, so I just put it here. I am kind off new to sfml programming, but i know much c++. I have read that lua is a great scripting language. So I am wondering if there is any c++, lua, sfml tutorials out there?

3
SFML projects / Strategy, building Hospital/Mall
« on: February 01, 2016, 12:52:08 pm »
Hi, I am a little new to SFML but know C++, I am planning on making a game like Prison Architect but with a hospital, or shopping mall. But I am wondering if someone wanted to work with me, PM me if interessted, or reply here with your skype or email.

4
General / Scrolling Background
« on: January 20, 2016, 05:38:16 pm »
Hi, I am trying to make a platform game, and have made an animation sprite, and a scrolling background by myself. I tried to make a scrolling background when I am walking backwards but I can't make it. Here is the relevant code. How can I make it so it will scroll if i walk backwards?

Code: [Select]
void main_game::ScrollingBackground(){
if (background1->getPosition().x < -background1->getGlobalBounds().width){
std::cout << "Out on the right side\n";
this->background1->setPosition(sf::Vector2f(this->background1->getGlobalBounds().width - 1, -50));
}
else if (background2->getPosition().x < -background2->getGlobalBounds().width){
std::cout << "Out on the right side\n";
this->background2->setPosition(sf::Vector2f(this->background2->getGlobalBounds().width - 1, -50));
}
}


5
General / DeltaTime
« on: January 11, 2016, 08:59:40 pm »
Hi, I am new to SFML and trying to make a moving rectangle. I am wondering if this is the correct use of deltaTime


while (window.isOpen()){
                sf::Event event;
               
                time = clock.restart();
                float dt = time.asSeconds();

                while (window.pollEvent(event)){

                        sf::Vector2f playerXY;
                       
                        if (acceleration > 1)
                                acceleration = 1;

                        if (event.type == sf::Event::Closed)
                                window.close();

                        else if (sf::Keyboard::isKeyPressed(sf::Keyboard::A)){
                                acceleration += 0.1;
                                playerXY = sf::Vector2f(-150.0f * dt, 0.0f);
                        }

                        else if (sf::Keyboard::isKeyPressed(sf::Keyboard::D)){
                                acceleration += 0.1;
                                playerXY = sf::Vector2f(150.0f * dt, 0.0f);
                        }
                        else{
                                acceleration = 0.2;
                        }

                        std::cout << dt << std::endl;

                        playerXY *= acceleration;

                        player.move(playerXY);
                       
                }
                window.clear();
                window.draw(player);
                window.display();
        }
 

6
General / Loading texture failing
« on: July 28, 2015, 11:32:55 pm »
Hi, im new to SFML and trying to load a texture. But I get an error message
failed to load image "images/SplashScreen.png". Reason: Unable to open file.
I have added the images folder to every class but it wont work. Does anyone know why? I use SDML 2.3

7
General / SFML Window Quiting when I start program
« on: July 28, 2015, 03:12:54 pm »
Hi, I just started at a pang tutorial. It's made from SFML 1.6 but I have found and corrected what's wrong and updated it to the newest version. But I seem to have a error, whenever I load the window it quits. I can't seem to find out whats wrong. Heres my code

Game.h:

I have added the headers and everything else

Code: [Select]
public:
static void Start();

private:
static bool IsExisting();
static void GameLoop();

enum GameState { Unititialized, ShowingSplash, Paused,
ShowingMenu, Playing, Exiting };

static GameState _gameState;
static sf::RenderWindow _mainWindow;

Game.cpp
Code: [Select]
#include "stdafx.h"
#include "Game.h"

void Game::Start(void)
{
if (_gameState != Unititialized)
return;

_mainWindow.create(sf::VideoMode(1024, 768, 32), "Pang!");
_gameState = Game::Playing;

while (!IsExisting())
{
GameLoop();
}

_mainWindow.close();
}

bool Game::IsExisting()
{
if (_gameState == Game::Exiting)
return false;
else
return true;
}

void Game::GameLoop()
{
sf::Event currentEvent;
while (_mainWindow.pollEvent(currentEvent))
{

switch (_gameState)
{
case Game::Playing:
{
_mainWindow.clear(sf::Color(255, 0, 0));
_mainWindow.display();

if (currentEvent.type == sf::Event::Closed)
{
_gameState = Game::Exiting;
}
break;
}
}
}
}


Game::GameState Game::_gameState = Unititialized;
sf::RenderWindow Game::_mainWindow;

stadfax.h:
Code: [Select]
#pragma once

#include "targetver.h"

#include <stdio.h>
#include <tchar.h>

#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/Audio.hpp>

#include <map>
#include <iostream>
#include <cassert>

Thanks in advance

8
General / Rotate sprite around mouse
« on: June 12, 2015, 04:30:35 pm »
Hi,
I have been trying SFML for 3 weeks soon. I've found this thing about rotating a sprite around the mouse. From long range it looks good. But the clooser it comes the more unaccurat it becomes. My image is 960 x 540

Heres the relevant code:

Quote
Game::Game()
   : mWindow(sf::VideoMode(WindowWidth, WindowHeight), WindowName, sf::Style::Close)
   , mPlayerTexture()
   , mPlayer()
   , mIsMovingDown(false)
   , mIsMovingLeft(false)
   , mIsMovingRight(false)
   , mIsMovingUp(false)
{
   if (!mPlayerTexture.loadFromFile("Media/Texture/eagle.png"))
   { }
   mPlayer.setTexture(mPlayerTexture);
   mPlayer.setScale(sf::Vector2f(0.25, 0.25));
   mPlayer.setOrigin(sf::Vector2f(120.f, 135.f));
}

void Game::lookAtMouse(sf::RenderWindow &win)
{
   sf::Vector2f curPos = mPlayer.getPosition();
   sf::Vector2i position = sf::Mouse::getPosition(win);

   const float PI = 3.14159265;

   float dx = curPos.x - position.x;
   float dy = curPos.y - position.y;

   float rotation = (atan2(dy, dx)) * 180 / PI;

   mPlayer.setRotation(rotation + 180);
}

Pages: [1]
anything