Skip to content

Instantly share code, notes, and snippets.

@clooth
clooth / process_manager.h
Created September 20, 2013 09:36
example
struct Process
{
Process* next_;
Process* previous_;
void (*function_)(void* caller_ptr, Purpose purpose);
unsigned int id;
//
// TextureManager.h
// Grand
//
// Created by Nico Hämäläinen on 9/21/13.
// Copyright (c) 2013 Nico Hämäläinen. All rights reserved.
//
#ifndef __Grand__TextureManager__
#define __Grand__TextureManager__
@clooth
clooth / mapscroll.cpp
Created September 23, 2013 10:51
map scroll
auto panMapLeft = [&mapView] (float speed, float time) { mapView.move(-speed * time, 0.f); };
auto panMapRight = [&mapView] (float speed, float time) { mapView.move(speed * time, 0.f); };
auto panMapUp = [&mapView] (float speed, float time) { mapView.move(0.f, -speed * time); };
auto panMapDown = [&mapView] (float speed, float time) { mapView.move(0.f, speed * time); };
// Map scroll
float mapScrollSpeed = 1000.f; // The speed of the scrolling
if (event.type == sf::Event::KeyPressed)
{
// Pan left
void Game::run()
{
sf::Clock clock;
sf::Time timeSinceLastUpdate = sf::Time::Zero;
while (mWindow.isOpen())
{
sf::Time elapsedTime = clock.restart();
timeSinceLastUpdate += elapsedTime;
while (timeSinceLastUpdate > TimePerFrame)
{
// Map edge scrolling
if (mousePosition.x < mapScrollTreshold && mousePosition.x >= 0) {
mapScrollSpeed += (mapScrollSpeed - mousePosition.x) * 1.5f;
panMapLeft(mapScrollSpeed, TimePerFrame);
}
if (mousePosition.x >= window.getSize().x - mapScrollTreshold
&& mousePosition.x <= window.getSize().x) {
mapScrollSpeed += (window.getSize().x - mousePosition.x) * 1.5f;
panMapRight(mapScrollSpeed, TimePerFrame);
// Map scrolling functions
auto panMap = [&mapView, &minimapView] (float speed, int dir) {
float timeValue = TimePerFrame.asSeconds();
float moveValue = speed * timeValue;
if (dir == 0) { mapView.move(-moveValue, 0.f); minimapView.move(-moveValue, 0.f); }
if (dir == 1) { mapView.move(moveValue, 0.f); minimapView.move(moveValue, 0.f); }
if (dir == 2) { mapView.move(0.f, -moveValue); minimapView.move(0.f, -moveValue); }
if (dir == 3) { mapView.move(0.f, moveValue); minimapView.move(0.f, moveValue); }
};
// Map scrolling functions
auto panMap = [&mapView, &minimapView] (float speed, int dir) {
float timeValue = TimePerFrame.asSeconds();
float moveValue = speed * timeValue;
if (dir == 0) { mapView.move(-moveValue, 0.f); minimapView.move(-moveValue, 0.f); }
if (dir == 1) { mapView.move(moveValue, 0.f); minimapView.move(moveValue, 0.f); }
if (dir == 2) { mapView.move(0.f, -moveValue); minimapView.move(0.f, -moveValue); }
if (dir == 3) { mapView.move(0.f, moveValue); minimapView.move(0.f, moveValue); }
};
@clooth
clooth / edgescroll.cpp
Created September 23, 2013 15:38
View Edge Scrolling
// Map scrolling functions
auto panMap = [&mapView, &minimapView] (float speed, int dir) {
float timeValue = TimePerFrame.asSeconds();
float moveValue = speed * timeValue;
if (dir == 0) { mapView.move(-moveValue, 0.f); minimapView.move(-moveValue, 0.f); }
if (dir == 1) { mapView.move(moveValue, 0.f); minimapView.move(moveValue, 0.f); }
if (dir == 2) { mapView.move(0.f, -moveValue); minimapView.move(0.f, -moveValue); }
if (dir == 3) { mapView.move(0.f, moveValue); minimapView.move(0.f, moveValue); }
};
@clooth
clooth / fail
Created September 26, 2013 17:54
Check dependencies
warning: no rule to process file '/Users/nico/Development/Clash/Clash/lua' of type folder for architecture x86_64
Ld /Users/nico/Library/Developer/Xcode/DerivedData/Clash-bzzjyeknflrxrvezjpmtiemmampa/Build/Products/Debug/Clash.app/Contents/MacOS/Clash normal x86_64
cd /Users/nico/Development/Clash
setenv MACOSX_DEPLOYMENT_TARGET 10.8
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -L/Users/nico/Library/Developer/Xcode/DerivedData/Clash-bzzjyeknflrxrvezjpmtiemmampa/Build/Products/Debug -L/usr/local/lib -L/usr/local/Cellar/boost/1.54.0/lib -F/Users/nico/Library/Developer/Xcode/DerivedData/Clash-bzzjyeknflrxrvezjpmtiemmampa/Build/Products/Debug -F/Library/Frameworks -F/usr/local/Frameworks -F/Library/Frameworks -filelist /Users/nico/Library/Developer/Xcode/DerivedData/Clash-bzzjyeknflrxrvezjpmtiemmampa/Build/Inter
@clooth
clooth / customsegue.m
Created September 27, 2013 19:24
segue
//
// HorizontalSlideSegue.m
// YouLapse
//
// Created by Nico Hämäläinen on 9/27/13.
// Copyright (c) 2013 YouLapse Oy. All rights reserved.
//
#import "HorizontalSlidePushSegue.h"