“SIGT & LIGHT” demo in Python using PyGame

A few days ago I stumbled upon the SIGHT & LIGHT demo by /u/nutcasenightmare over at /r/GameDev: http://www.reddit.com/r/gamedev/comments/205r78/sight_light_how_to_create_a_2d_visibilityshadow/

I was quite amazed by it and surely wanted to give it a shot in Python using PyGame – and here we are now!

SIGHT & LIGHTSource code at GIST: https://gist.github.com/marcusmoller/9538871
PyGame.org entry: http://pygame.org/project-SIGHT+%26+LIGHT+demo-2885-4706.html

PKGBUILDs for drtv-dl and FLAT

Been an ArchLinux user for more than 4 years now, but never gotten around adding any packages to the AUR yet.

But now I have!

I’ve managed to setup my first two PKGBUILDs ever. One is for my own project, drtv-dl, the other one is for FLAT, a 7DFPS entry.

The AUR packages can be found here:

Please be aware that these are my very first two PKGBUILDs, so if there are any problems or mistakes, please report them to me ASAP.

WriteProcessMemory() equivalent under GNU/Linux

Earlier today I stumbled upon a post called Reverse Engineering for newbies that explained briefly how to find the address of certain variables in applications (ah, the good old Cheat Engine days…) and also how modifying said address should be done in C/C++.

GNU/Linux does not have the WriteProcessMemory function, but instead we’ve got ptrace! Using ptrace we are able to attach to a process and use PTRACE_POKEDATA to modify the value of an address.

We will then be able to set up a similar function to WriteProcessMemory under GNU/Linux:

bool WriteProcessMemoryNix(pid_t pid, void *addr, void *data)
    // attach to process
    if (ptrace(PTRACE_ATTACH, pid) != 0)
        return false;

    // wait for process to stop
    waitpid(pid, NULL, WUNTRACED);

    // modify the address
    if (ptrace(PTRACE_POKEDATA, pid, addr, data) != 0)
        return false;

    // detach from the process
    ptrace(PTRACE_DETACH, pid);

    // everything went ok
    return true;

To use this function, you would first need to find the memory address of the variable you want to change. I did this for the gold amount in the game Rogue Legacy using the tool scanmem.

I would then use my new WriteProcessMemoryNix() function to modify the gold address to 999 gold:

if (WriteProcessMemoryNix(1679, (void *)0x7fd01459e598, (void *)999))
        std::cout << "Success!" << std::endl;

The process id (pid) of Rogue Legacy was found using the ps command.

Combining single sprite animations into a spritesheet using Shell (and Imagemagick)

JPhilipp over at OpenGameArt recently submitted 700 (!) sprites, with walking animation included. You can find the sprites here: http://opengameart.org/content/700-sprites

When developing games I prefer to use spritesheets with all animation frames in a single image file, rather than an image for every single animation frame.

So what to do? Use Shell!
I wrote a quick (and dirty) Shell script to combine the animation frames into a single spritesheet for each sprite. I am nowhere near an expert in Shell, but I managed to get it working, so I’m happy.

The script placed the different walking animation frames into a single spritesheet for each sprite and the result was:

jli1You can download all the spritesheets here!

Source code:


mkdir combined
for f in *.gif
    if ls combined/$short".png" &> /dev/null; then
        echo "file exists"
        montage -tile x1 -geometry +0+0 -background none $short*.gif combined/$short.png
        convert combined/$short.png -transparent white combined/$short.png

PyWeek #17 is over

The timing couldn’t be better. I needed a post to fill up my otherwise empty blog and PyWeek #17 has just ended.

My entry, Miner, ended up with an overall score of 3.09 out of 5 – nothing great, nor nothing bad!


I wrote the game in Python (2.7) and PyGame since that was what I felt most comfortable using for a one-week game. It’s quick, it’s easy and I feel comfortable using it.
I had originally planned spending the whole week on the game, but the nice weather made me change my plans and take a trip to Sweden instead. I did manage to finish the game (sort of) and it was great fun. Can’t wait for the next PyWeek!

You can find all the PyWeek #17 ratings here: http://pyweek.org/17/ratings/