Jump to content
IGNORED

new game problem to make srpite collision


Bob_63

Recommended Posts

Hello all

I am a just beginning to develop a new game for Atari Lynx console

up to know, I have follow the tutorial in the famous "diary of a atari lynx developer" and for me , it 's fine to begin, thanks

 

problem :

I can't manage to make srpite collision

In fact, I don't have the TGI_detectioncollision function, so I have used the fonction tgi_ioctl(5, 1);

 

and I would like to sceening the depository value for One of my sprite, but nothing appear on screen.

 

=> I try after that to fit in the link assembly the - C lynx-coll.cfg, but surprse : I don't succeed to compile my C code=> error appear (error 2 => function expected ).

After analysing standard lynx.cfg and lynx-coll.cfg, I have lot of differences,

 

My conclusion up to this day is that my version of assembler is obsolete...

 

 

Someone could help me. I have spend lot of time to try to solve my problem and now, i think that I am bloqued

 

Thanks a lot By advance.

 

 

 

Link to comment
Share on other sites

You are using Windows or Linux ?

 

You can see the name of the function in include / lynx.h. You use TGI_detectioncollision instead of tgi_setcollisiondetection. Maybe it's a first mistake, but using tgi_ioctl (5, 1) it's the same

#define tgi_setcollisiondetection(active) tgi_ioctl(5, (void*)(active))

Can you put your code for the the depository ?

Something like this would work and draw 0 on screen. Don't forget the drawing order. Maybe your text is under Sprite.

typedef struct {
  byte depository;
  SCB_REHV_PAL scb;
} sprite_collideable;

sprite_collideable robot =  {
  0x0,  {
    BPP_4 | TYPE_NORMAL, REHV,
    0x01,
    0, robot,
    20, 50, 0x0100, 0x0100,
    { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }
  }
};

tgi_sprite(&robot.scb);
itoa(robot.depository, text, 10);
tgi_outtextxy(30, 48, text);
  • Like 1
Link to comment
Share on other sites

Hello Chopper Commander

Thanks a lot for your Help!!

FIrst , I 'm working on windows

With your Help , I can now screening the depository number

I also have the tgi_setcollisiondetection function working well

 

=> this is a big step

 

but, strangly, when I make my sprite collision, the depository number stay at 0

I'm wondering If I need to add in my Make File the attribute -C Lynx-coll.cfg?

on this case, the compilation don't work anymore

Link to comment
Share on other sites

Hello Chopper Commander

Thanks a lot for your Help!!

FIrst , I 'm working on windows

With your Help , I can now screening the depository number

I also have the tgi_setcollisiondetection function working well

 

=> this is a big step

 

but, strangly, when I make my sprite collision, the depository number stay at 0

I'm wondering If I need to add in my Make File the attribute -C Lynx-coll.cfg?

on this case, the compilation don't work anymore

 

Ok, I don't working on windows.

 

Post your code ! Have you declare other sprite depository like the example, you should have 8 :

sprite_collideable wall =

{

0x0,

{

BPP_4 | TYPE_NORMAL,

REHV,

0x8,

0,

singlepixel_data,

50, 20, 0x0a00, 0x1a00,

{ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }

}

};

You need Lynx-coll.cfg only if you have this file. If you only have one .c file like hello world template, you don't need to add the cfg.

You can see an example here that should work for windows: http://sebastianmihai.com/main.php?t=49

 

Humm sorry, I made a mistake,.. your Nickname : => Tonma (and not chopper commander) ...

:-D

Link to comment
Share on other sites

Hello Tonma

this is my code :

the only one difference I have seen is the byte variable=> in windows, I have to use unsigned or signed char in place of byte.

 

for the sprite declaration: (smiley and soucoupe)

typedef struct {
unsigned char depository;
SCB_REHV_PAL scb;
} sprite_collideable;

sprite_collideable smileydraw = {
0x0,
{
BPP_4 | TYPE_NORMAL,
REHV,
0x1,
0,
&smiley,
30, 30, 0x0100, 0x0100,
{ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }
}
};



sprite_collideable soucoupedraw =
{
0x0,
{
BPP_4 | TYPE_NORMAL,
REHV,
0x8,
0,
&soucoupe,
30, 30 ,0x0100, 0x0100,
{ 0x06, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34 }
}
};

 

for the screening:

void show_screen()
{
tgi_clear();
tgi_sprite(&soucoupedraw.scb);
tgi_sprite(&smileydraw.scb);
itoa(smileydraw.depository, text, 10);
tgi_outtextxy(50, 90, text);
tgi_updatedisplay();
while (tgi_busy());
}


the initialization void :

void initialize()
{
tgi_install(&lynxtgi);

joy_install(&lynxjoy);
tgi_init();

tgi_setcollisiondetection(1);
CLI();
while (tgi_busy());
setpalette(palette_Atlantis),
tgi_clear();
}

 

 

And the main void :

 

void main(void)
{
initialize();
show_screen();

}

Not possible for me to make appear a depositary value different from 0 value. I try a lot of test (inverting the sprite apparition), moving sprite in the screen, moving the tgi_setcollisiondetection(1); in place of byte, trying char, unsigned ans signed char, etc...

 

Thanks again to follow my post, this is a important help for a rookie as me!


Link to comment
Share on other sites

I try on Linux and it's working. The only thing, I don"t use lynxtgi but lynx_160_102_16, it's just the same file for linux I think.

You draw the sprites in the right order.

I do not know for the mistake, maybe someone on windows may find.

Do you have some warnings when compile ?

#include <lynx.h>
#include <tgi.h>
#include <6502.h> 
#include <joystick.h>
#include <stdlib.h>
#include <conio.h>


char allcolors_data[17] =  
{
  0x04, 0x98, 0x09, 0x18,  // 1 0011 0000 0001 0010 0011 000 
  0x04, 0x9a, 0x2b, 0x38,  // 1 0011 0100 0101 0110 0111 000 
  0x04, 0x9c, 0x4d, 0x58,  // 1 0011 1000 1001 1010 1011 000 
  0x04, 0x9e, 0x6f, 0x78,  // 1 0011 1100 1101 1110 1111 000 
  0x00
};

typedef struct {
 unsigned char depository;
  SCB_REHV_PAL scb;
} sprite_collideable;


sprite_collideable smileydraw =   
{      
  0x0,     
  {  
  BPP_4 | TYPE_NORMAL,
  REHV,
  0x01,
  0,
  allcolors_data,
  30, 30, 0x0100, 0x0100,  
  { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }  
  }
};

sprite_collideable soucoupedraw =
{
  0x0,     
  {    
  BPP_4 | TYPE_NORMAL,
  REHV,
  0x8,
    0,
    allcolors_data,
  32, 32 ,0x0100, 0x0100,
  { 0x01, 0x23, 0x45, 0xbc, 0xde, 0xf0, 0x12, 0x34 }
}
};

char text[16];


void main(void) {
  tgi_install(&lynx_160_102_16);
  tgi_init();
  tgi_setcollisiondetection(1);
  CLI();
  tgi_setcolor(COLOR_GREEN);
  while (tgi_busy())
	   ;
	   
	while (1) {
	  while (tgi_busy())
	   ;
	   
	  tgi_clear();
	  
	  tgi_sprite(&soucoupedraw.scb);
    tgi_sprite(&smileydraw.scb);
	
	
    itoa(smileydraw.depository, text, 10);
    tgi_outtextxy(50, 90, text);   
	  tgi_updatedisplay();
  
    }
}

You must use a while to run show_screen () again and again. Otherwise after the function "show_screen" the software stops.

void main(void)
{
 initialize();
   while(1) {
       show_screen();
   }

}

Have you tried with the same picture. I think it's perfect collision so if you two sprites collide with the transparent color, they do not collide.

game.zip

post-44532-0-48694000-1487778268_thumb.png

Link to comment
Share on other sites

Hello Tonma

Thanks a lot for your precious help

unfortunately, i think Windows version work differently with collision. Maybe, it is the reason why I fail in the collision programming

I m going to continue to looking for the solution and if I'll find something I will give you the solution

Bye

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...