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

Pages: [1]
1
General / console disable c++
« on: March 31, 2023, 01:43:33 pm »
how can i hide console c++ from showing, like when i send my project to my friend his console to be hidden

2
General / Re: [Solved]Textures aren't showing
« on: January 23, 2023, 09:57:09 am »
tq

3
General / [Solved]Textures aren't showing
« on: January 21, 2023, 12:03:42 pm »
The textures arent showing
I will put my project below
In advance, thank you
main.cpp:
// Comp issues win any rez other tham 1920*1080
#include "smth.hpp"
#include "grass.cpp"
using namespace sf;
int main()
{
    init_grass();
    Object player, bg;
    player.position = {960, 100};
    bg.position = {0, 0};
    if (!player.texture.loadFromFile("Images/big-floppa-player.png") || !bg.texture.loadFromFile("Images/bg.jpg"))
    {
        return -1;
    }
    player.position = {0, 100};
    player.sprite.setTexture(player.texture);
    bg.sprite.setTexture(bg.texture);
    RenderWindow window(sf::VideoMode(1920, 1080), "Super Floppa", Style::Fullscreen);
    Clock clock;
    while (window.isOpen())
    {
        Event event;
        while (window.pollEvent(event))
        {
            sf::Time elapsed = clock.restart();
            float dt = elapsed.asSeconds();
            if (event.type == Event::Closed || Mouse::isButtonPressed(Mouse::Right))
                window.close();
            if (Keyboard::isKeyPressed(Keyboard::A))
                player.position += {-10.f, 0.f};
            if (Keyboard::isKeyPressed(Keyboard::D))
                player.position += {10.f, 0.f};
            if (Keyboard::isKeyPressed(Keyboard::W))
                player.position += {0.f, -10.f};
            if (Keyboard::isKeyPressed(Keyboard::S))
                player.position += {0.f, 10.f};
            window.clear();
            window.draw(bg.sprite);
            window.draw(grass);
            display_smth(player, window);
            while (!touch_grass_lol(player, grass))
            {
                player.position += {0.f, 10.f};
            }
            std::cout << player.position.x << &#39;-&#39; << player.position.y << &#39;\n&#39;;
            window.display();
            if (dt < 1.f / 60.f)
            {
                sleep(sf::seconds(1.f / 60.f - dt));
            }
        }
    }
    return 0;
}
// no credits here
//------------------
grass.cpp
#include <SFML/Graphics.hpp>
#include "smth.hpp"
using namespace sf;
RectangleShape grass(Vector2f(1920.f, 100.f));
void init_grass()
{

    Texture grass_tex;
    if (!grass_tex.loadFromFile("Images/grass.png"))
    {
        std::cout << -1192919929;
    }
    grass.setTexture(&grass_tex);
    grass.setPosition(0, 980);
}
// my friend ... needs to (-insert someone name-)
bool touch_grass_lol(Object &object, RectangleShape grass)
{
    if (object.sprite.getGlobalBounds().intersects(grass.getGlobalBounds()))
        return 1;
    return 0;
}
 
smth.hpp
#pragma once
#include <SFML/Graphics.hpp>
#include <SFML/Window/VideoMode.hpp>
#include <SFML/System.hpp>
#include <iostream>
#include <cmath>
const double PI = 3.14159265358979323846;
struct Object
{
    sf::Vector2f position;
    float angle;
    sf::Sprite sprite;
    sf::Texture texture;
};

void update_pos(Object &object1, Object &object2)
{
    object1.position = object2.position;
}
void moveObject_angle(Object &object, float &distance, float &angle)
{
    // Calculate the displacement in the x and y directions
    float dx = distance * cos(angle * PI / 180.0f);
    float dy = distance * sin(angle * PI / 180.0f);

    // Update the object&#39;s position
    object.position.x += dx;
    object.position.y += dy;

    // Update the object&#39;s sprite position
    object.sprite.setPosition(object.position);
}
void display_smth(Object &object, RenderWindow &window)
{
    object.sprite.setPosition(object.position);
    window.draw(object.sprite);
}
/*bool jump(int f)
{
    int o = f;
    f-= o/10;
    player.position += player.position += {0.f, f};
    if(player.getGlobalBounds.itersects.grass.sprite)
    return 0;
}*/

4
General / Re: Error
« on: January 17, 2023, 03:41:36 pm »
didnt helped
heres the full code:
main.cpp
// Comp issues win any rez other tham 1920*1080
#include "smth.hpp"
using namespace sf;
void display_smth(Object &object, RenderWindow &window)
{
    object.sprite.setPosition(object.position);
    window.draw(object.sprite);
}
int main()
{
    Object player = {{960, 540}, 0}, bg{{1000, 1000}, 0}, bullet{{0, 0}, 0};
    if (!player.texture.loadFromFile("Images/big-floppa-player.png") || !bg.texture.loadFromFile("Images/bg.jpg"))
    {
        return -1;
    }
    //   grass.texture.loadFromFile("Images/grass.png");
    //  grass.sprite.setTexture(grass.texture);
    player.sprite.setOrigin(player.sprite.getTexture()->getSize().x * player.sprite.getScale().x / 2, player.sprite.getTexture()->getSize().y * player.sprite.getScale().y / 2);
    bg.sprite.setTexture(bg.texture);
    RenderWindow window(sf::VideoMode(500, 500), "Super Floppa", Style::Fullscreen);
    while (window.isOpen())
    {
        Event event;
        // bg.sprite.setScale(VideoMode::getDesktopMode()/bg.sprite.getTexture()->getSize().x);
        bg.sprite.setScale(window.getSize().x / bg.sprite.getTexture()->getSize().x, window.getSize().y / bg.sprite.getTexture()->getSize().y);
        while (window.pollEvent(event))
        {
            if (event.type == Event::Closed || Mouse::isButtonPressed(Mouse::Right))
                window.close();
            //  moveObject(object, 10, 45); <-bullet

            if (Keyboard::isKeyPressed(Keyboard::A))
                player.position += {-10.f, 0.f};
            if (Keyboard::isKeyPressed(Keyboard::D))
                player.position += {10.f, 0.f};
            if (Keyboard::isKeyPressed(Keyboard::W))
                player.position += {0.f, -10.f};
            if (Keyboard::isKeyPressed(Keyboard::S))
                player.position += {0.f, 10.f};

            window.draw(bg.sprite);
            display_smth(player, window);
            display_smth(bullet, window);
            /* for (int i = 1; i <= window.getSize().y / 100; i++)
            {
                grass.position = {int(window.getSize().x) + 100 * i, 0};
                display_smth(grass, window);
            }
            */

            window.display();
            window.clear();
            //     if (!bullet.sprite.getGlobalBounds().intersects.bg.getGlobalBounds())
            //     update_pos(bullet, player);
        }
    }
    // std::cout << window.getSize().x / bg.sprite.getTexture()->getSize().x;
    return 0;
}
smth.hpp
#pragma once
#include <SFML/Graphics.hpp>
#include <SFML/Window/VideoMode.hpp>
#include <iostream>
#include <cmath>
const double PI = 3.14159265358979323846;
struct Object
{
    sf::Vector2f position;
    float angle;
    sf::Sprite sprite;
    sf::Texture texture;
} grass;

void update_pos(Object &object1, Object &object2)
{
    object1.position = object2.position;
}
void moveObject_angle(Object &object, float &distance, float &angle)
{
    // Calculate the displacement in the x and y directions
    float dx = distance * cos(angle * PI / 180.0f);
    float dy = distance * sin(angle * PI / 180.0f);

    // Update the object&#39;s position
    object.position.x += dx;
    object.position.y += dy;

    // Update the object&#39;s sprite position
    object.sprite.setPosition(object.position);
}
/*bool jump(int f)
{
    int o = f;
    f-= o/10;
    player.position += player.position += {0.f, f};
    if(player.getGlobalBounds.itersects.grass.sprite)
    return 0;
}*/
plsssss

5
General / Re: Error
« on: January 16, 2023, 03:51:06 pm »
.

6
General / Re: Error
« on: January 16, 2023, 02:34:30 pm »
in the same folder or at src/dll? (src is the source folder)

7
General / [Please help]Error
« on: January 15, 2023, 09:07:09 am »
mingw32-make: *** [Makefile:11: run] Error -1073741819
code:
all:run
CC=g++
CFLAGS=-O1 -Wall -std=c++17 -Wno-missing-braces -I ./include/ -L ./lib/ -lsfml-graphics -lsfml-window -lsfml-system
TARGET=floppa.exe
SRC=src/main.cpp
DEPS=src/smth.hpp
$(TARGET): $(SRC) $(DEPS) Makefile
   $(CC) $< -o $@ $(CFLAGS)
build: $(TARGET)
run: build
   ./$(TARGET)

8
General / Re: Error
« on: January 12, 2023, 03:13:23 pm »
i fixed it somehow, but now the window crashes instantly
heres the code:

#include <SFML/Graphics.hpp>
#include <cmath>
using namespace sf;
const float PI = 3.14159265358979323846;

// Struct to represent an object with a position, angle, sprite, and texture
struct Object
{
    sf::Vector2f position;
    float angle;
    sf::Sprite sprite;
    sf::Texture texture;
};

// Function to move the object by a specified distance at the specified angle
void moveObject(Object &object, float distance, float angle)
{
    // Calculate the displacement in the x and y directions
    float dx = distance * cos(angle * PI / 180.0f);
    float dy = distance * sin(angle * PI / 180.0f);

    // Update the object's position
    object.position.x += dx;
    object.position.y += dy;

    // Update the object's sprite position
    object.sprite.setPosition(object.position);
}

int main()
{
    // Create an object at position (0, 0) with an angle of 0 degrees
    Object player = {{0, 0}, 0}, bg{{0, 0}, 0};

    // Load an image for the object's texture
    if (!player.texture.loadFromFile("Images/big-floppa-player.png") || !bg.texture.loadFromFile("Images/bg.jpg"))
    {
        return -1;
    }

    // Set the object's texture for the sprite
    player.sprite.setTexture(player.texture);
    bg.sprite.setTexture(bg.texture);
    RenderWindow window(sf::VideoMode(500, 500), "Super Floppa", Style::Fullscreen);
    while (window.isOpen())
    {
        Event event;
        while (window.pollEvent(event))
        {
            if (event.type == Event::Closed || Mouse::isButtonPressed(Mouse::Right))
                window.close();
            //  moveObject(object, 10, 45);
            window.draw(bg.sprite);
            window.draw(player.sprite);
            if (Keyboard::isKeyPressed(Keyboard::A))
                player.position += {-1.f, 0.f};
            if (Keyboard::isKeyPressed(Keyboard::D))
                player.position += {1.f, 0.f};
            if (Keyboard::isKeyPressed(Keyboard::W))
                player.position += {0.f, -1.f};
            if (Keyboard::isKeyPressed(Keyboard::S))
                player.position += {0.f, 1.f};
            window.draw(player.sprite);
            window.display();
        }


        return 0;
    }
}
 

9
General / [SOLVED]Error
« on: January 11, 2023, 01:56:34 pm »
I have this errors:
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible ./lib//libsfml-graphics.a when searching for -lsfml-graphics
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible ./lib/\libsfml-graphics.a when searching for -lsfml-graphics
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible ./lib//libsfml-window.a when searching for -lsfml-window
(there are others)
and this makefile:
CC = g++
CFLAGS=-O1 -Wall -std=c++17 -Wno-missing-braces -I ./include/ -L ./lib/ -lsfml-graphics -lsfml-window -lsfml-system
SOURCES = src/main.cpp
OBJECTS = $(SOURCES:.cpp=.o)
EXECUTABLE = floppa

all: $(SOURCES) $(EXECUTABLE)
   
$(EXECUTABLE): $(OBJECTS)
        $(CC) $(CFLAGS) $(OBJECTS) -o $@

.cpp.o:
        $(CC) $(CFLAGS) $< -o $@
 
helppppppppppp

10
Feature requests / Re: Angle between two object
« on: November 23, 2022, 02:30:11 pm »
ok thx

11
Feature requests / Angle between two object
« on: November 22, 2022, 03:27:24 pm »
how to calculate angle between two sprites/objects? :) ik this was asked before but i am a noob so i didnt understand

Pages: [1]
anything