project mag-lamp

This is a recipe for a quick bodged together magnifying glass+light for soldering etc.

ingredients:

1 x old lamp (found mine in the loft, who knows where you could get a lamp)

1 x flourescent lamp from some sort of microscope/etc, from a junkpile

1 x piece of scrap wood

1 x magnifying glass (from a helping hand, OHP etc)

Tape

First, admire your lamp, lovely…

sad lamp is sad

Tape the magnifying glass into the ring light

lets hope the tape doesn't melt...

drill a hole in the wood, bolt it to the lamp, and tape the light to the piece of wood

Admire the new creation, wonder at its wonders, and use it to see small things while supplying enough light to work in a basement

And lastly, post a picture of your housemate with a lampshade on his head onto the internet :)


code snippet:php/lmsensors report:why you shouldn’t use insulation tape to keep fans on

Just a short snippet for this one, first the code:

php
 $sensor_data=shell_exec("sensors | grep 'Temp\|temp\|fan\|Fan'");
 $sensor_data=nl2br($sensor_data);
 print($sensor_data."<br><br>");
 ?>

yeah, real short. This is also very simple, it runs sensors (part of lmsensors),
and greps for the fan and temperatures, calls nl2br to add a
wherever there
is a ‘\n’ in the shells output, and prints it out to view.

Why you shouldn’t attach fans with insulation tape

Tape is great stuff, it’s quick, easy and sticks things together with very little fuss, which is why i use A LOT of it (my machines are mainly held together with various types of tape)

The one thing tape (specifically insulation tape) isn’t too great for, is sticking to things that get hot, like a heatsink.

So i was sat at work, checking a few things on my server through ssh, when without any error it died, turns out the fan i taped to the heatsink had fallen off, and the 90nm 2.8GHz hyper-threaded pentium 4 was sat there happily overheating.  Thankfully the hardware failsafe kicked in and killed the server.

here’s what the cooling looks like now:

1xcpu fan(stock core 2 fan)

2xbackup fans(form an xbox 360 cooler, little green ones, one on the chipset as that gets pretty hot, and one on the side of the cpu sink incase the main one fails)

1xcase fan(to get the air out the case)

ooh shiny!

Let’s hope the hot glue stands up better to heat than the tape, either that or i might actually have to spend some money on the server…


pandora competition progress/code snippet

Alright, so there’s this pandora platforming competition, that i decided to bother with, seeing what the competition already has i’m not looking at prize money, but it’s something fun to do all the same.

project name: for now? pjump, which is bound to change once i design levels etc for it

progress: basic physics, collisions, jumping and gravity done, still limited to once screenful of level as i haven’t programmed the screen scrolling yet

Basic system:

A level is drawn as a bmp, no restrictions on size (apart from memory limits etc), and can look like anything that can be drawn in a bmp really

Along with each level is a level_map.bmp file, which specifies the map for the level, using different colours for solid objects, death traps, enemies and the like

Currently defined colours: 0xFF00FF : solid objects, ground etc

This map is then used for collisions with the solid objects, and starting placement of enemies etc, which will be specified as another colour in the map, so it can be scanned at load time and all the objects can be put into their respective linked lists/whathaveyous (therefore level loading might take a while, so this idea might have to go, and just use a config file for the other objects.  this would make it a lot faster, but harder to get objects positioning right when creating a level)

collisions are handled simply by checking the row of pixels next to the player, although ignoring the first and last X pixels (X is defined differently for each direction), this is so the player can a: walk up slopes (without walking into the floor would be good aswell eventually), and doesn’t float in mid air when near the edge of a cliff.

 

The physics:

here’s a simplified version of the main game loop for basic player physics/clipping (in psuedo code, this won’t compile, and probably has mistakes anyway :P )

(note: this is missing the screen scrolling, and clipping with the edges of the screen)

while(level is running)
{
get_input() //get the state of the input, and set pressed_* variable accordingly

//do some very basic physics to calculate where we want to be at the end of the frame
if(pressed_left)
    if(x_delta>(0-X_DELTA_MAX))
       x_delta--;
else
    if(x_delta<0)
        x_delta++; //slow the player down until stop
if(pressed_right)
    if(x_delta<X_DELTA_MAX)
        x_delta++;
else
    if(x_delta>0)
        x_delta--; //slow the player down until stop

//do the movement for this frame, for loops are used to generate smooth movement (a single flip at the end of the frame produces jerkyness
//in theory this actually does all the movement at the start of the frame, and have a delay afterwards, which would also make jerky movement, but it seems to work ok
if(x_delta<0)
    if(can move left (i.e not solid to the left, or edge of screen etc)
       for(i=0;i>x_delta;i++)
        {
           player->x--;
           update_player();//redraw the player at the new location
        }
    else
        x_delta=0; //player can't move, so stop the player moving
 else if(x_delta>0)
    else if(can move left)
        for(i=0;i<x_delta;i++)
        {
            player->x++;
            update_player();
        }
    else
       x_delta=0;

//gravity
if(we can fall(i.e not colliding downwards))
    if(gravity_t<GRAVITY)
        gravity_t+=GRAVITY_DELTA; //if we're not at terminal velocity, increase velocity by GRAVITY_DELTA (acceleration)
    for(i=0;i<gravity_t;i++) //smooth movement loop
    {
        if(we can fall) //need another check here as we are changing position
        {
            player->y++; //in SDL positive y is downwards
            update_player();
        }
    }
else //we can't fall, so set things to not fall.  and if we're on the ground we're obviously not jumping either
{
    gravity_t=0;
    jumping=0;
}

//jumping -- this is the most complicated, but is pretty simple once you think about it
if((we are on the ground) && pressed_jump && !jumping) //if we can jump, and have requested a jump
{
    jumping=1; //we are now jumping
    jump_orig_y=player->y; //store the start of our jump for use in calculating the jump height etc
}

if(jumping)
{
    if(!touching the ceiling)
    {
        //as jump_t goes from 0 to 0.5, this will increase the jump height in a sin curve, to JUMP_HEIGHT
        player->y=jump_orig_y-(JUMP_HEIGHT*sin(jump_t*PI);
        jump_t+=JUMP_T_DELTA; //increase jump_t for the next frame in the jump
        if(jump_t>0.5) //if we've reached the top of the jump, we're not jumping anymore
        {
             jump_t=0;
             jumping=0;
             pressed_jump=0;
        }
    }
    else //we've hit the ceiling, cancel the jump
    {
        jump_t=0;
        jumping=0;
        pressed_jump=0;
    }
}

draw stuff to the screen();

while(SDL_GetTicks()<last_frame+FRAME_TIME);  //loop until we've waited long enough for this frame

last_frame=SDL_GetTicks(); //update the last_frame time
}

 

 

 


programming snippet: SDL initialisation

Okay, so these code snippets are probably going to be totally useless to most people as there won’t be much indepth knowledge (unless i come across something particularly interesting i guess), but i need to get used to documenting code better/etc, so where better to start eh?

Include the SDL header, and define a pointer to the screen surface (this should be SDL_Surface *screen and not SDL_Surface* screen,because  SDL_Surface is a struct)

#include <SDL.h> //this will need -I/usr/include/SDL or similar for compiling
SDL_Surface *screen;

Start the sdl subsystems that are needed, values being SDL_INIT_VIDEO, SDL_INIT_AUDIO, SDL_INIT_JOYSTICK and a few others

if (SDL_Init(SDL_INIT_VIDEO) != 0) {
     fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
     return 1;
 }
 

Setup the screen surface with the needed size/depth/flags, and make sure it worked, if it didn’t return and go to whatever the cleanup code is

common flags: SDL_FULLSCREEN, SDL_SWSURFACE, SDL_HWSURFACE, SDL_DOUBLEBUF

 screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, BPP,SDL_SWSURFACE);
 if (screen == NULL) {
     fprintf(stderr, "Unable to set video mode: %s\n", SDL_GetError());
     return 1;
 }

disable the cursor, this only really matters if the program is running in fullscreen mode

SDL_ShowCursor(SDL_DISABLE);

still going

Well this place hasnt seen much love really, due to real life and things like that, so heres a bit of an update.

Gadgets: got an archos 70 android tablet, its very shiny and is being used to type this
Real life: even if you care its not going on a public blog :p
projects: all in a state of limbo tbh, no major advancements on any, only one being finished is a quick port of classic invaders to the pandora. 

Someday i might find something interesting to put here but dont bet on it, only interesting thing right now is that im taking part in the pandora homebrew platformer competition, and have so far written a basic framework with sprites and physics, excluding collisions.  Once its done ill probably do an indepth look at it, in the hopes that it either becomes useful for anyone, or improves my quite shockingly poor writing skills, that badly need improving even if its just so i can read my logbooks

oh and i hit 1000 posts on dingoonity, so wont be visting there any longer, too much happening in the pandora world and i dont even have a dingoo that works anymore


Website

Just a quick note incase anyone actually looks on here :)
Website is live, isnt anything special really

www.gfrancisdev.co.uk


Mufasa v3

image

image

Well its time I updated this place, so have a picture or two of my new casemod, no real name yet as its not quite finished, main features are the monitor built into the side of the case, and new frontpanel made from some sheet steel, original case was generic beigebox


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: