Im programming a very simple pongclone for learning purposes and I got a bit of a problem . As soon as I uncomment the ball panel it crashes, but when I comment the flagsline it works again(although no visible ball). It is really strange. At first I thought it crashed because of me using the same bitmap for both paddle panels, but it made no difference when I defined two BMAPs. I even tried different sizes of the imagefile since it worked when I used the paddleimage. I have tried 32x32, 64x64 and 128x128 for the ball.
Otherwise it works fine.
#include <acknex.h>
#include <default.c>
BMAP* paddle = "paddle.png";
BMAP* ball = "balls.png";
BMAP* paddletwo = "paddle.png";
PANEL* paddle_one =
{
bmap = paddle;
pos_x = 64;
pos_y =250;
layer = 1;
flags = SHOW;
}
PANEL* paddle_two =
{
bmap = paddletwo;
pos_x = 736;
pos_y = 250;
layer = 1;
flags = SHOW;
}
//PANEL* ball =
//{
// bmap = ball;
// pos_x = 400;
// pos_y = 350; CRASHES WHEN USED!
// layer = 2;
// flags = SHOW;
//}
function player_one()
{
if (key_w)
{
if (paddle_one.pos_y > 0)
{
paddle_one.pos_y -= 1;
wait(1);
}
}
if (key_s)
{
if (paddle_one.pos_y < 500)
{
paddle_one.pos_y += 1;
wait(1);
}
}
wait(1);
}
function player_two()
{
if (key_pgup)
{
if (paddle_two.pos_y > 0)
{
paddle_two.pos_y -= 1;
wait(1);
}
}
if (key_pgdn)
{
if (paddle_two.pos_y < 500)
{
paddle_two.pos_y += 1;
wait(1);
}
}
}
function main()
{
screen_size.x = 800;
screen_size.y = 600;
while(1)
{
player_one();
player_two();
wait(1);
}
}