Gamestudio Links
Zorro Links
Newest Posts
Pause button for evaluation shell?
by AndrewAMD. 08/13/26 17:16
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 08/10/26 12:46
phantom() not defined in indicators.c
by jcl. 08/07/26 11:45
Accepting new programming clients
by AndrewAMD. 08/06/26 21:25
Fun Arcade Car Physics (nfs style)
by Ezzett. 08/02/26 21:11
ZorroGPT
by TipmyPip. 07/31/26 22:56
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
0 registered members (), 2,135 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LapHoan, ZeonLau, Ponti233, riggi89, shuhari
19230 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Getting crash while using panels #442477
06/23/14 13:22
06/23/14 13:22
Joined: Nov 2010
Posts: 7
Sweden
J
jakk_zeven Offline OP
Newbie
jakk_zeven  Offline OP
Newbie
J

Joined: Nov 2010
Posts: 7
Sweden
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.

Code:
#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);
	}
	
}


Re: Getting crash while using panels [Re: jakk_zeven] #442478
06/23/14 13:33
06/23/14 13:33
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Use separate names for PANELs and BMAPs (or any other objects in general), for example bmp_ball and pnl_ball.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Getting crash while using panels [Re: Superku] #442480
06/23/14 13:36
06/23/14 13:36
Joined: Nov 2010
Posts: 7
Sweden
J
jakk_zeven Offline OP
Newbie
jakk_zeven  Offline OP
Newbie
J

Joined: Nov 2010
Posts: 7
Sweden
That did the trick! Thank you laugh


Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1