sfml

Cannot compile SFML project using cmake

那年仲夏 提交于 2021-01-28 06:06:52
问题 I am trying to set up a new c++/sfml project using cmake/g++ on windows but the build keeps on failing with linking errors. There are still errors if I use SFML_STATIC or not. I have looked up the problem but none of the answers so far remove the errors. - \build - \cmake_modules - FindSFML.cmake - \SFML - CMakeLists.txt - config.h.in - main.cpp CMakeLists.txt cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR) project(myproject) set(myproject_VERSION_MAJOR 1) set(myproject_VERSION_MINOR 0)

Texture.loadFromFile doesn't work

徘徊边缘 提交于 2021-01-27 12:28:53
问题 I am using SFML 2.2 and Visual Studio Express 2013. I simply want to load a texture and apply it to a sprite just like it is done in the tutorials at http://www.sfml-dev.org/tutorials/2.2/graphics-sprite.php. The problem is that texture.loadFromFile() doesn't work at all for me. I have tried to place my file in a thousand different places and I always get the same result. Finally I decided to use the full path, same problem. I also tried different formats: PNG, GIF, JPG, BMP. I also tried to

Setup CMake with SFML in VS2017

寵の児 提交于 2020-12-05 20:37:18
问题 Just like in CLion I want to use SFML with Visual Studio 2017, but I'm still learning cmake and I don't know the commands or the logic of how cmake works at all. I've just seen some posts and got this litle script. Note: I downloaded the latest version of sfml in the link provided, I just taked the extrated directory and put alongside CMakeLists.txt in my folder #sets up the minimum version of cmake cmake_minimum_required(VERSION 3.9) #how the project will be called project (space_impact)

Setup CMake with SFML in VS2017

对着背影说爱祢 提交于 2020-12-05 20:32:50
问题 Just like in CLion I want to use SFML with Visual Studio 2017, but I'm still learning cmake and I don't know the commands or the logic of how cmake works at all. I've just seen some posts and got this litle script. Note: I downloaded the latest version of sfml in the link provided, I just taked the extrated directory and put alongside CMakeLists.txt in my folder #sets up the minimum version of cmake cmake_minimum_required(VERSION 3.9) #how the project will be called project (space_impact)

SFML texture displaying as a white box

浪子不回头ぞ 提交于 2020-08-25 03:53:36
问题 I have a texture and sprite in a base class that is being extended by another class, however when drawn, the sprite displays as a white box. I know this is something to do with the sprite losing it's link to the texture object, but I'm kind of new to C++, so I'm not really sure how it happened. Here is the code (I've removed some of the irrelevant parts to cut down the size): Pickup.h: #ifndef PICKUPS_PICKUP_H #define PICKUPS_PICKUP_H #include <SFML\Graphics.hpp> #include "..\Player.h"

SFML texture displaying as a white box

与世无争的帅哥 提交于 2020-08-25 03:53:24
问题 I have a texture and sprite in a base class that is being extended by another class, however when drawn, the sprite displays as a white box. I know this is something to do with the sprite losing it's link to the texture object, but I'm kind of new to C++, so I'm not really sure how it happened. Here is the code (I've removed some of the irrelevant parts to cut down the size): Pickup.h: #ifndef PICKUPS_PICKUP_H #define PICKUPS_PICKUP_H #include <SFML\Graphics.hpp> #include "..\Player.h"

C/C++百行代码实现热门游戏-消消乐

南笙酒味 提交于 2020-08-12 02:03:38
游戏设计 首先我们需要使用第三方框架,这里我使用的是sfml,不会使用sfml在我的上几篇文章当中-扫雷(上)有详细的开发环境搭建介绍 首先准备图片资源 一张背景图片,一张宝石图片 窗口初始化加载图片 Texture t1; t1.loadFromFile(“images/bg2.png”); 当鼠标第一次单击时,记录下位置,第二次单击又记录一下位置,如果两个小方块相邻就交换位置,如果不相邻如图c的位置则,不发生变化 判断行或列如果三张一样的图片相邻,清除一下图片,进行刷新 实列 # include <SFML/Graphics.hpp> # include <SFML/Audio.hpp> # include <time.h> using namespace sf ; # define GAME_ROWS_COUNT 8 # define GAME_COLS_COUNT 8 int ts = 57 ; // 每一个游戏小方块区域的大小 bool isMoving = false ; bool isSwap = false ; // 相邻位置的第几次单击,第2次单击才交换方块 int click = 0 ; Vector2i pos ; //鼠标单击时的位置 Vector2i offset ( 15 , 273 ) ; int posX1 , posY1 ; //第一次单击的位置

百行代码手撸扫雷(下)c/c++

我只是一个虾纸丫 提交于 2020-08-09 03:36:20
在上一篇文章中已经带大家如何搭建开发环境了 需求分析 这里是一个8*8的地图 地雷随机分布数字表示周围一共有多少颗雷 数字1表示红色区域内有1课雷,2表示有两颗 如何显示数字 右上角没有如何判断呢?行加1或列加一不就越界了吗,所以为了帮面条件判断我们把8行8列改成10行10列 游戏实现 先包含头文件 #include <SFML/Graphics.hpp> #include <SFML/Audio.hpp> 初始化窗口大小,就类似于我们要搭台唱戏一样,需要一个舞台这个舞台大小需要多大,我们需要指定一下舞台大小,不指定怎么知道需要多大的舞台呢?这就是初始化 初始化窗口: RenderWindow window(VideoMode(800, 800), “Canxin-MINE”); RenderWindow window(VideoMode(窗口宽度,窗口高度),“窗口右上角的描述信息”); 宽为x坐标,高为y坐标; 获取当前鼠标点击的x坐标和y坐标 Vector2i pos = Mouse::getPosition(window); 我们要把鼠标的x坐标和y坐标转化成行和列,就需要鼠标的x坐标除以方块的像素宽度,y坐标也是一样 # include <SFML/Graphics.hpp> # include <SFML/Audio.hpp> # include <time.h>