About rooks

rooks's Trophies

rooks's Archive

Foreach in c++

Posted by
Thursday, October 28th, 2010 10:58 pm

Hi

I created simple helper that might help few of you who use c++ with STL. It adds foreach to the c++ that traverses over all of the STL container, so the code is more readable, like in this example:

#include <cstdio>
#include <vector>
#include "foreach.h"

int main()
{
    // make int vector and fill it
    vector<int> k;
    for (int i=0; i<10; ++i) k.push_back(i);

    // show what the upper loop filled
    foreach_ (it, k) printf("%i ",(*it));
    printf("\n");

    // show all the data, but get rid of 4
    // http://en.wikipedia.org/wiki/Tetraphobia :)
    foreachdel_ (it, k)
    {
        if (*it == 4) it=k.erase(it);
        printf("%i ",(*it));
    }
    printf("\n");

    return 0;
}

Will result in following:

0 1 2 3 4 5 6 7 8 9
0 1 2 3 5 6 7 8 9

More on my blog:  http://pleasanthacking.com/2010/06/17/foreach-in-cpp/

I hope some of you will find it useful during compos :)

The idea is set

Posted by
Friday, April 17th, 2009 11:13 pm

Idea:

Big flame chases little hero and throws fireballs at him. Fireballs set flames to the level, so the hero must constantly run. Little hero uses supersoaker to put down an fireball, soak it with water and kick back at the big flame to put it out. He can also use it to fire-proof some parts of the level.

Deployment:

C++, STL, OpenGL, OpenAL

This is my 3rd attempt at LudumDare, all previous ones failed because i wanted my code to be too pretty. This time its kludge time, wish me luck :)

food and such

Posted by
Sunday, December 7th, 2008 5:49 am

food: onions + tofu + corn + tomato + mun shrooms + oregano and such + mozarella, green tea(yerba mate rosamonte), orange (nom’ed)

So far

Posted by
Saturday, December 6th, 2008 12:45 pm

So far so – so. At least I have some idea what I am doing :)

Things figured out:

  • General idea for a game – aiming for skyroads made using modern tools, but I’ll be also happy with just one no frills circuit running
  • Map making and general what to click where in blender
  • How to make a car sim in bullet physics lib
  • KDevelop started working after emergency switch from 4.0alpha to 3.5
  • Build chain for making windows .exe’s in linux :)

Things to do:

  • Sleep
  • Eat
  • Exporting maps and models from blender into my c++ app
  • Some sort of drawing it in c++
  • Ripping needed stuff from bullet examples and evolve it into sth game’ish
  • Model for the racer itself?
  • ????
  • Profit.

And for those who are curious it looks like this:

Be amazed, be very amazed.

fail

Posted by
Sunday, April 20th, 2008 5:58 pm

note to self:

  • never ever try to go for implementing keyboard on directinput during LD, too much time wasted there
  • make sure that build chain works. i spent too much time figuring out why linux based mingw dont want to build stuff after adding 3rd party lib to the project and rewriting makefile to serve some less significant stuff
  • dont get flu/cold just in time for LD – slows down your thinking :)

on positive side I managed to write pretty good code to serve as a base for my other projects, so yay me :)

it was a cool and fun race, see you all on next LD :)

Time to sleep

Posted by
Sunday, April 20th, 2008 12:26 am

Idea is ready.

Opengl code for graphics is ready (i do windows .exe totally in linux :) ).

Time to sleep now, when i wake up i just implement the idea and be happy about it, maybe even add sounds if time permits :)

Hopefully catching some zzz’s will heal up cold I caught just in time for LD11…

Wish me luck, if I succed you will have a kick-ass game :)

Starting at less than 6h till deadline :)

Posted by
Sunday, December 16th, 2007 1:28 pm

So this is where I start… about 5.5 h to deadline.  Right now I have one sheet of paper with gameplay plans, 0 lines of code, some gfx made and a cat to help me betatest when its done. Wish me luck :)

start

[cache: storing page]