Friday, December 2, 2016
Wednesday, November 2, 2016
HUD!
main.cpp
-----------------------------------------------------------------------------------------------
#include <SFML/Graphics.hpp>
#include "FuelBar.h"
using namespace sf;
int main()
{
RenderWindow window(VideoMode(270, 480), "HUD!", Style::Close);
//////////////////////////////////////////////
FuelBar mFuelBar;
mFuelBar.setPos(20.f, 300.f);
while (window.isOpen())
{
Event event;
while (window.pollEvent(event))
{
if (event.type == Event::Closed)
window.close();
}
window.clear();
/////////////////////////////////////////////
for (Sprite n : mFuelBar.get()) {
window.draw(n);
}
window.display();
}
return 0;
}
BarBackground.cpp
--------------------------------------------------------------------------------------
#include <SFML/Graphics.hpp>
#include <string>
#include "BarBackground.h"
BarBackground::BarBackground(string fileName)
{
mTex.loadFromFile(fileName);
mSpr.setTexture(mTex);
mSpr.setPosition(0, 0);
}
BarBackground::~BarBackground()
{
}
void BarBackground::setPos(float x, float y)
{
mSpr.setPosition(x, y);
}
Sprite& BarBackground::get()
{
return mSpr;
}
BarBackground.h
-----------------------------------------------------------------------------
#pragma once
using namespace std;
using namespace sf;
class BarBackground
{
public:
BarBackground(string);
~BarBackground();
void setPos(float, float);
Sprite& get();
private:
Texture mTex;
Sprite mSpr;
};
BarIcon.cpp
-------------------------------------------------------------------------------------
#include <SFML/Graphics.hpp>
#include <string>
#include "BarIcon.h"
BarIcon::BarIcon(string fileName)
{
mTex.loadFromFile(fileName);
mSpr.setTexture(mTex);
mSpr.setPosition(0, 0);
}
BarIcon::~BarIcon()
{
}
void BarIcon::setPos(float x, float y)
{
mSpr.setPosition(x, y);
}
Sprite& BarIcon::get()
{
return mSpr;
}
BarIcon.h
-------------------------------------------------------------------
#pragma once
using namespace std;
using namespace sf;
class BarIcon
{
public:
BarIcon(string);
~BarIcon();
void setPos(float, float);
Sprite& get();
private:
Texture mTex;
Sprite mSpr;
};
BarFuel.cpp
--------------------------------------------------------------------------
#include <SFML/Graphics.hpp>
#include "FuelBar.h"
#include <string>
FuelBar::FuelBar() : mBarBackground("graphics/hud.png"), mBarIcon("graphics/fuel.png")
{
fuel = 100.f;
}
FuelBar::~FuelBar()
{
}
void FuelBar::setPos(float x, float y)
{
// Background
mBarBackground.setPos(x, y);
// Status
// lIcon
mBarIcon.setPos(x + 5, y + 5);
}
vector<Sprite>& FuelBar::get()
{
mFuelSprites.push_back(mBarBackground.get());
mFuelSprites.push_back(mBarIcon.get());
return mFuelSprites;
}
void FuelBar::updateFuelBar()
{
}
BarFuel.h
-----------------------------------------------------------------------------
#include "BarBackground.h"
#include "BarIcon.h"
#pragma once
using namespace std;
using namespace sf;
class FuelBar
{
public:
FuelBar();
~FuelBar();
void setPos(float, float);
vector<Sprite>& get();
void updateFuelBar();
private:
float fuel;
vector<Sprite> mFuelSprites;
BarBackground mBarBackground;
BarIcon mBarIcon;
};
Friday, October 28, 2016
Wednesday, October 12, 2016
VS Code + SFML
VS Code
https://code.visualstudio.com
c_cpp_properties.json
{
"configurations": [
{
"name": "Mac",
"includePath": ["/usr/include"],
"browse" : {
"limitSymbolsToIncludedHeaders" : true,
"databaseFilename" : ""
}
},
{
"name": "Linux",
"includePath": ["/usr/include"],
"browse" : {
"limitSymbolsToIncludedHeaders" : true,
"databaseFilename" : ""
}
},
{
"name": "Win32",
"includePath": ["c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include",
"C:/SFML-2.4.1/include",
"C:/mingw32/include"
],
"browse" : {
"limitSymbolsToIncludedHeaders" : true,
"databaseFilename" : ""
}
}
]
}
tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "g++",
"isShellCommand": true,
"args": [
"-g", "-o", "main.exe",
"-std=c++11",
"main.cpp",
"-IC:/SFML-2.4.1/include",
"-LC:/SFML-2.4.1/lib",
"-lsfml-graphics-d",
"-lsfml-window-d",
"-lsfml-system-d"
],
"showOutput": "always"
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/main.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true,
"linux": {
"MIMode": "gdb"
},
"osx": {
"MIMode": "lldb"
},
"windows": {
"MIMode": "gdb",
"miDebuggerPath": "c:/mingw32/bin/gdb.exe"
}
},
{
"name": "C++ Attach",
"type": "cppdbg",
"request": "attach",
"program": "${workspaceRoot}/main.exe",
"processId": "${command.pickProcess}",
"linux": {
"MIMode": "gdb"
},
"osx": {
"MIMode": "lldb"
},
"windows": {
"MIMode": "gdb"
}
}
]
}
https://code.visualstudio.com
c_cpp_properties.json
{
"configurations": [
{
"name": "Mac",
"includePath": ["/usr/include"],
"browse" : {
"limitSymbolsToIncludedHeaders" : true,
"databaseFilename" : ""
}
},
{
"name": "Linux",
"includePath": ["/usr/include"],
"browse" : {
"limitSymbolsToIncludedHeaders" : true,
"databaseFilename" : ""
}
},
{
"name": "Win32",
"includePath": ["c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include",
"C:/SFML-2.4.1/include",
"C:/mingw32/include"
],
"browse" : {
"limitSymbolsToIncludedHeaders" : true,
"databaseFilename" : ""
}
}
]
}
tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "g++",
"isShellCommand": true,
"args": [
"-g", "-o", "main.exe",
"-std=c++11",
"main.cpp",
"-IC:/SFML-2.4.1/include",
"-LC:/SFML-2.4.1/lib",
"-lsfml-graphics-d",
"-lsfml-window-d",
"-lsfml-system-d"
],
"showOutput": "always"
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/main.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true,
"linux": {
"MIMode": "gdb"
},
"osx": {
"MIMode": "lldb"
},
"windows": {
"MIMode": "gdb",
"miDebuggerPath": "c:/mingw32/bin/gdb.exe"
}
},
{
"name": "C++ Attach",
"type": "cppdbg",
"request": "attach",
"program": "${workspaceRoot}/main.exe",
"processId": "${command.pickProcess}",
"linux": {
"MIMode": "gdb"
},
"osx": {
"MIMode": "lldb"
},
"windows": {
"MIMode": "gdb"
}
}
]
}
Tuesday, October 11, 2016
Atom + SFML
Atom
https://atom.io/
Packages:
minimap
minimap-hightlight-selected
hightlight-selected
hightlight-line
find-and-replace
file-icons
linter-gcc
GCC Include path: C:/mingw64/include, C:/SFML-2.4.0/include
gpp-compiler
C++ Compiler options: -IC:/SFML-2.4.0/include -LC:/SFML-2.4.0/lib -lsfml-graphics -lsfml-window -lsfml-system
atom-beautify
C,C++: clang-format
(win7x64, x32: mingw64 - 6.1, clang - 3.9, sfml - 2.4).
Saturday, July 2, 2016
LinuxMint 18
Qt 5.7
--------------
hxxps://www.qt.io
--------------
hxxps://www.qt.io
sudo apt-get install build-essential libgl1-mesa-dev
sudo apt-get install cmake
sudo apt-get install valgrind
..download
chmod +x qt-linux-opensource-XXX-x86-offline.run
./qt-linux-opensource-XXX-x86-offline.run
Clang 3.8
-----------
hxxp://llvm.org
ppa: deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-3.8 main
key: wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
sudo apt-get install clang-3.8 clang-3.8-doc libclang-common-3.8-dev libclang-3.8-dev libclang1-3.8 libclang1-3.8-dbg libllvm-3.8-ocaml-dev libllvm3.8 libllvm3.8-dbg lldb-3.8 llvm-3.8 llvm-3.8-dev llvm-3.8-doc llvm-3.8-examples llvm-3.8-runtime clang-format-3.8 python-clang-3.8 lldb-3.8-dev liblldb-3.8-dbg
sudo apt-get install clang
BOOST
-----------
hxxp://www.boost.org
sudo apt-get install libboost-all-dev
Clion SFML
-----------
cmake_minimum_required(VERSION 3.5) project(untitled) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # Define sources and executable set(EXECUTABLE_NAME "untitled") add_executable(${EXECUTABLE_NAME} main.cpp) # Detect and add SFML set(CMAKE_MODULE_PATH "/usr/share/SFML/cmake/Modules" ${CMAKE_MODULE_PATH}) find_package(SFML 2 REQUIRED system window graphics network audio) if(SFML_FOUND) include_directories(${SFML_INCLUDE_DIR}) target_link_libraries(${EXECUTABLE_NAME} ${SFML_LIBRARIES}) endif()
Tuesday, April 26, 2016
Ubuntu 16.04 LTS
Ubuntu 16.04 LTS
----------------
sudo apt-get install build-essential libgl1-mesa-dev
Qt, Clion, ...
SFML 2.3.2
----------------
sudo apt-get install libsfml-dev
test code: hxxp://www.sfml-dev.org/tutorials/2.3/start-linux.php
g++ -std=c++11 -c main.cpp
g++ main.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system
./sfml-app
GLFW 3.1.2
----------------
sudo apt-get install libglfw3-dev
test code: hxxp://www.glfw.org/docs/latest/quick.html
g++ -std=c++11 -c main.cpp
g++ main.o -o glfw-app -lGL -lGLU -lglfw -lX11 -lXxf86vm -lXrandr -lpthread -lXi
?(-lXinerama -lXcursor -ldl)
./glfw-app
----------------
sudo apt-get install build-essential libgl1-mesa-dev
Qt, Clion, ...
SFML 2.3.2
----------------
sudo apt-get install libsfml-dev
test code: hxxp://www.sfml-dev.org/tutorials/2.3/start-linux.php
g++ -std=c++11 -c main.cpp
g++ main.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system
./sfml-app
GLFW 3.1.2
----------------
sudo apt-get install libglfw3-dev
test code: hxxp://www.glfw.org/docs/latest/quick.html
g++ -std=c++11 -c main.cpp
g++ main.o -o glfw-app -lGL -lGLU -lglfw -lX11 -lXxf86vm -lXrandr -lpthread -lXi
?(-lXinerama -lXcursor -ldl)
./glfw-app
Subscribe to:
Posts (Atom)
