Posted By: Harstad
2d platform game. Moving a character - 01/12/09 22:15
Ok, so I'm trying to make a simple 2d Platform game, just to get started.
this is what I got so far:
#include <acknex.h>
#include <default.c>
BMAP* background = "second.bmp";
BMAP* gras = "gress.bmp";
BMAP* person = "player.bmp";
PANEL* new_background = //this is the background.
{
pos_x = 0;
pos_y = 0;
bmap = background;
layer = 1;
flags = VISIBLE;
}
PANEL* new_ground = //this is the ground for the player to walk on.
{
pos_x = 0;
pos_y = 0;
bmap = gras;
layer = 3;
flags = OVERLAY | VISIBLE;
}
PANEL* Player_2 = //this is the player.
{
pos_x = 250;
pos_y = 450;
layer = 2;
bmap = person;
flags = VISIBLE | OVERLAY;
}
PANEL* Player_1 =
{
pos_x = 250;
pos_y = 425;
Layer = 2;
bmap = "player.bmp";
flags = VISIBLE | OVERLAY;
}
function move_right()
{
new_background.pos_x += 5;
wait (1);
}
function quit_program()
{
sys_exit (NULL);
}
function main ()
{
video_mode = 10;
video_screen = 1;
screen_color.blue = 150;
handle = media_loop ("123.mp3",NULL,50);
on_q = quit_program;
while(1)
{
new_background.pos_x -=15*(key_d-key_a)*time_step; //this enables the player to walk forwards and backwards
new_ground.pos_x -=15*(key_d-key_a)*time_step;
if (key_w)
{
Player_2.pos_y -=30*time_step;
}
else
{
Player_2.pos_y +=30*time_step;
}
if (Player_2.pos_y > 450)
{
Player_2.pos_y = 450;
}
wait(1);
}
}
this is what I got so far:
#include <acknex.h>
#include <default.c>
BMAP* background = "second.bmp";
BMAP* gras = "gress.bmp";
BMAP* person = "player.bmp";
PANEL* new_background = //this is the background.
{
pos_x = 0;
pos_y = 0;
bmap = background;
layer = 1;
flags = VISIBLE;
}
PANEL* new_ground = //this is the ground for the player to walk on.
{
pos_x = 0;
pos_y = 0;
bmap = gras;
layer = 3;
flags = OVERLAY | VISIBLE;
}
PANEL* Player_2 = //this is the player.
{
pos_x = 250;
pos_y = 450;
layer = 2;
bmap = person;
flags = VISIBLE | OVERLAY;
}
PANEL* Player_1 =
{
pos_x = 250;
pos_y = 425;
Layer = 2;
bmap = "player.bmp";
flags = VISIBLE | OVERLAY;
}
function move_right()
{
new_background.pos_x += 5;
wait (1);
}
function quit_program()
{
sys_exit (NULL);
}
function main ()
{
video_mode = 10;
video_screen = 1;
screen_color.blue = 150;
handle = media_loop ("123.mp3",NULL,50);
on_q = quit_program;
while(1)
{
new_background.pos_x -=15*(key_d-key_a)*time_step; //this enables the player to walk forwards and backwards
new_ground.pos_x -=15*(key_d-key_a)*time_step;
if (key_w)
{
Player_2.pos_y -=30*time_step;
}
else
{
Player_2.pos_y +=30*time_step;
}
if (Player_2.pos_y > 450)
{
Player_2.pos_y = 450;
}
wait(1);
}
}