Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
5 registered members (Dico, AndrewAMD, TipmyPip, NewbieZorro, Grant), 15,791 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Problem with aum83 2d workshop #352240
01/02/11 13:26
01/02/11 13:26
Joined: Nov 2010
Posts: 7
Sweden
J
jakk_zeven Offline OP
Newbie
jakk_zeven  Offline OP
Newbie
J

Joined: Nov 2010
Posts: 7
Sweden
I started to look at the aum83 2d workshop but when i was done with the code it didnt really work as expected.

I try to keep the code clean and separated into several files. Thats where it gets weird here. I separated it into main, functions and player. The code is almost exactly like in the workshop with few exceptions but it just wont work.

The function that reads the txt file and draws the tiles work perfectly. But the player panel never shows up on the screen. I have tried comparing the files with each other and I cant find whats wrong, its probably something small I overlooked or I have gotten it all wrong in the big picture. Either way I could really use some advice on what to do here. I dont want to collect all the code in one big file, it just gets messy when the code grows bigger later.

Main.C
#include <acknex.h>
#include <default.c>
#include "functions.c"
#include "player.c"

function main()
{
fps_max = 60;
video_mode = 11;
video_depth = 32;
video_screen = 1;
vec_set(screen_color, vector(178,153,128));
level_load(NULL);
read_level_data();
player_startup();
}


Functions.C

#define init_x 376
#define init_y 360
#define tile_width 64
#define tile_height 52

STRING* data_str = "#20";
STRING* temp_str = "#20";

PANEL* temp_pan;

function read_level_data()
{
var level_handle, string_size, index, layer_value;
VECTOR tile_pos;
layer_value = 10;
tile_pos.x = init_x;
tile_pos.y = init_y;
level_handle = file_open_read("level.txt");
wait (3);
while (file_str_read(level_handle, data_str) != -1)
{
index = 0;
string_size = str_len(data_str);
while (index < string_size)
{
str_cpy (temp_str, data_str);
str_clip(temp_str, index);
str_trunc(temp_str, string_size - index - 1);

if(str_cmp(temp_str, "d") == 1)
{
temp_pan = pan_create("bmap = dirt.png;", layer_value);
temp_pan.pos_x =tile_pos.x;
temp_pan.pos_y =tile_pos.y;
temp_pan.flags |= VISIBLE;
}

if(str_cmp(temp_str, "g") == 1)
{
temp_pan = pan_create("bmap = grass.png;", layer_value);
temp_pan.pos_x = tile_pos.x;
temp_pan.pos_y = tile_pos.y;
temp_pan.flags |= VISIBLE;
}

if(str_cmp(temp_str, "p")==1)
{
temp_pan = pan_create("bmap = plain.png;", layer_value);
temp_pan.pos_x = tile_pos.x;
temp_pan.pos_y = tile_pos.y;
temp_pan.flags |= VISIBLE;
}

if(str_cmp(temp_str, "s")==1)
{
temp_pan = pan_create("bmap = stone.png;", layer_value);
temp_pan.pos_x = tile_pos.x;
temp_pan.pos_y = tile_pos.y;
temp_pan.flags |= VISIBLE;
}

if(str_cmp(temp_str, "t")==1)
{
temp_pan = pan_create("bmap = terrain.png;", layer_value);
temp_pan.pos_x = tile_pos.x;
temp_pan.pos_y = tile_pos.y;
temp_pan.flags |= VISIBLE;
}

if(str_cmp(temp_str, "w")==1)
{
temp_pan = pan_create("bmap = water.png;", layer_value);
temp_pan.pos_x = tile_pos.x;
temp_pan.pos_y = tile_pos.y;
temp_pan.flags |= VISIBLE;
}

tile_pos.x += tile_width;
index += 1;

}

layer_value += 1;
tile_pos.x = init_x;
tile_pos.y += tile_height;
}

file_close(level_handle);
}

Player.C

PANEL* player_pan;

function player_startup()
{
VECTOR player_speed;
var horizontal_speed = 0;
var vertical_speed = 0;
player_pan = pan_create("bmap = player.png;", 150);
player_pan.pos_x = 383;
player_pan.pos_y = 225;
player_pan.flags |= VISIBLE;
player_pan.center_x = player_pan.size_x * 0.5;
player_pan.center_y = player_pan.size_y;

while(1)
{
vec_set(player_speed.x, accelerate(horizontal_speed, 2 * (key_cur - key_cul), 0.3));
player_pan.pos_x += player_speed.x;
vec_set(player_speed.x, accelerate(horizontal_speed, 2 *(key_cud - key_cuu),0.3));
player_pan.pos_y += player_speed.y;
if (key_cul + key_cur + key_cuu + key_cud)
{
player_pan.angle += 0.3 * sin(40 * total_ticks);
}
else
{
player_pan.angle = 0;
}
wait(1);
}
}

edit:
Since the workshops code works when I copy & paste it I dont think this matters, but Im using the free version of A8.

edit2:

Now it gets even weirder. I added the gem code as well and the gem shows up no problem, but still no playercharacter. I put it at the bottom in the player.c file.

PANEL* gem_pan;
SOUND* gem_wav = "gem.wav";
var game_score;

function gem_startup()
{
VECTOR gem_pos;
while(1)
{
gem_pan = pan_create("bmap = gem.png;",150);
gem_pan.pos_x = 200 + random(560);
gem_pan.pos_y = 150 + random(400);
gem_pan.flags |= VISIBLE;
while ((abs(player_pan.pos_x - gem_pan.pos_x) > 30) || (abs(player_pan.pos_y - gem_pan.pos_y) > 30))
{
wait(1);
}
snd_play(gem_wav,100,0);
game_score += 5;
ptr_remove(gem_pan);
wait(1);
}
}

Last edited by jakk_zeven; 01/02/11 15:05.
Re: Problem with aum83 2d workshop [Re: jakk_zeven] #352276
01/02/11 16:51
01/02/11 16:51
Joined: Dec 2010
Posts: 8
S
SQS Offline
Newbie
SQS  Offline
Newbie
S

Joined: Dec 2010
Posts: 8
The 2D-Workshop was made with A7. I don't know a lot about A8, but maybe there is one statement called different...

Re: Problem with aum83 2d workshop [Re: SQS] #352277
01/02/11 16:53
01/02/11 16:53
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
gem_pan.flags |= VISIBLE;

VISIBLE was replaced by SHOW - I don't know if that's the cause of your problem.


"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: Problem with aum83 2d workshop [Re: Superku] #352301
01/02/11 19:50
01/02/11 19:50
Joined: Nov 2010
Posts: 7
Sweden
J
jakk_zeven Offline OP
Newbie
jakk_zeven  Offline OP
Newbie
J

Joined: Nov 2010
Posts: 7
Sweden
It has nothing to do with VISIBLE since the workshop code works perfectly when I run that directly from the download. But I did change all VISIBLE to SHOW now and that has no effect. Its still only the tiles and gem that show up, the player remains invisible.

I also added a function that reads a second txt file to put some trees out as well and those show up no problem as well. Its only the player code that wont work. Its weird, because the code for the gem, tilemap and player are all similar since they all use panels. I have tried changing the layervalue for the player but that does nothing as well.

Re: Problem with aum83 2d workshop [Re: jakk_zeven] #352303
01/02/11 19:56
01/02/11 19:56
Joined: Aug 2009
Posts: 1,438
Spain
painkiller Offline
Serious User
painkiller  Offline
Serious User

Joined: Aug 2009
Posts: 1,438
Spain
try with: set(gem_pan, SHOW);


3D Gamestudio A8 Pro
AMD FX 8350 4.00 Ghz
16GB RAM
Gigabyte GeForce GTX 960 4GB
Re: Problem with aum83 2d workshop [Re: painkiller] #352306
01/02/11 20:01
01/02/11 20:01
Joined: Nov 2010
Posts: 7
Sweden
J
jakk_zeven Offline OP
Newbie
jakk_zeven  Offline OP
Newbie
J

Joined: Nov 2010
Posts: 7
Sweden
the gem is not the problem, but Ill try that with the player panel.

edit: Didnt work sadly. added set(player_pan,SHOW); to the main function but still no player.

Last edited by jakk_zeven; 01/02/11 20:04.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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