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

Pages: [1]
1
General / Collision Problem
« on: April 24, 2017, 04:35:52 am »
Accidentally posted this on the wrong board earlier today.  Sorry about that

I keep getting strange error from Visual Studio when I try to add collision detection to my game.  There errors all look like similar to this:
"...sfml\graphics\rect.inl(114): error C2589: '(': illegal token on right side of '::'"
I'm doing collision detection in the exact same way I've always done it, and trying other methods doesn't work either. 
Relevant Code:
if (isCollide(spr, spr2)) {
                        std::cout << "You win!!!! \n";
                }
bool isCollide(sf::Sprite spr1, sf::Sprite spr2) {
        return spr1.getGlobalBounds().intersects(spr2.getGlobalBounds());
}
 

I was wondering if it's an issue with how I set up SFML in VS...

2
Graphics / Re: Font problem
« on: April 24, 2017, 03:47:07 am »
Make sure it compiles successfully and that you run the new executable and not the old one. ;)
Already thought of it.  I'm not that dumb

3
Graphics / Font problem
« on: April 23, 2017, 09:58:33 am »
So originally in my new project I was using arial, but I switched to another font.  But for some reason it won't register the change I made.  It keeps saying "Failed to load font "arial.ttf" (failed to create the font face)" despite the fact that I changed the code, the files, etc.  I've tried moving the font files, deleting various files that visual studio generates, and I've made zero progress. 
Using VS17

#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <iostream>
#include <SFML/Graphics.hpp>
#include <string>
#include <iostream>
#include <vector>
#include <fstream>
/**
Main, has the game loop
*/

int main() {
        // Making the window
        sf::RenderWindow window(sf::VideoMode(1776, 1000), "Axis of Evil");
        window.setFramerateLimit(30);

        sf::Font fnt;
        if (!fnt.loadFromFile("cr.ttf")) {
                std::cout << "Could not load font\n";
        }

        /*
        Game loop
        */

        while (window.isOpen()) {
                // Allows the window to be closeable
                sf::Event e;
                while (window.pollEvent(e)) {
                        if (e.type == sf::Event::Closed)
                                window.close();
                }
                // Hides the console
                //HWND hWnd = GetConsoleWindow();
                //ShowWindow(hWnd, SW_HIDE);






                // Drawing to the SFML window
                window.clear();
                window.display();
        }
        return 0;
}

 
All of the code for my proj so far. 

4
General / Problem with a sprite
« on: March 14, 2017, 03:10:52 am »
Fairly new to SFML and I was trying to make a simple 2d shooter without using classes.  So instead I started using arrays, yet I can't get the laser beams/bullets to work right.  Here's all the relevant code

sf::Sprite sLasor[ARRAY_LENGTH];
int lasorCounter = 0;

if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space) && frameCounter > 30){
            lasorCounter++;
            frameCounter = 0;
            sLasor[lasorCounter].setPosition(fArwing.x + 65, fArwing.y);
        }
        if (lasorCounter >= 19){
            lasorCounter = 0;
        }
 if(sLasor[lasorCounter].getPosition().y > 0){
            sLasor[lasorCounter].move(0, -5);
        }
window.draw(sLasor[lasorCounter]);
 

The problem is that every time I press space, the lasers reset and the one I shot earlier just disappears.  If I don't shoot another one the bullet will continue going until it exits the screen. 

5
General / Re: Can't quite get it to work in Linix
« on: March 11, 2017, 07:34:53 am »
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}
It's literally just the code SFML has you use to test if it works
I would like to add that I was able to get this to work on windows in the past with Code Blocks and MINGW.  Now I can't get it to work on Linux with CodeBlocks and GCC.  I followed the instructions on how to get it working on CodeBlocks exactly

6
General / Can't quite get it to work in Linix
« on: March 11, 2017, 07:21:38 am »
I've almost got SFML working on my linux computer, but every time I test my code the window pops up for a second and immediately disappears.  I've tried messing around with the build settings as much as possible and there are no errors at compile-time.  All help is appreciated.

Pages: [1]