1

Hello dear friends

I was trapped for months. Write some code. But it's all bad.


I tried to study Sebastian Mihai's NEO THUNDER, but it was quite different from DATlib.


Shoot bullets and destroy enemies. How to write this in DATlib? If someone wants to provide some code. Thank you very much. Thank you.
avatar

2

Both dev_kit and Datlib can be programmed in C. The underlying code is in assembly. I suggest reviewing the code samples of Datlib to get a better idea about how they work.

Then check out some 2d shooter programming websites for how to detect collisions and move objects on the screen.
avatar

3

Thank you very much for your reply. Thank you very much.



I tried to look at the code, and I also collected some code.


I'm also trying to look at David Vandensteen's neocore.


His code is cool. But there are no bullets in the code.


Https://github.com/David-Vandensteen/neocore


The only bullet code I have is Sebastian Mihai's NEO THUNDER


But he didn't write it in DATlib.


I tried to put the bullet spirit out of the screen and then put it in. I tried to write it in DATlib, but it was too difficult for me, so I asked for help.


I know not many people use DATlib.


Because there are many game engines, and there are many examples of those engines.


So I just hope to see if it's possible to collect a DATlib bullet code.
avatar

4

The code for bullets is not in Datlib. You have to write it yourself.

Here is a example of how to create a bullet:

1. load image info: pic, position
//bullets for(i = 0; i < NUMBULLETS; i++) { bullets[i].x = 330;//off screen bullets[i].y = 0; bullets[i].width = 1; bullets[i].height = 4; bullets[i].xVel = 0; bullets[i].yVel = 1;// will need to update for sprite firing i.e. bullets vs. player bullets[i].alive = 0; bullets[i].hits = 1; bullets[i].shotAlive = 0; bullets[i].shotXorg = 5; bullets[i].shotYorg = 8; bullets[i].quadrant = ReturnQuadrant(330,0); bullets[i].lastShotTime = 0; pictureInit(&bullets[i].pic, &BULLETS, currentBaseSprite,currentBasePalette,330,0,FLIP_NONE); currentBaseSprite += BULLETS.tileWidth; } palJobPut(currentBasePalette, BULLETS.palInfo->count,BULLETS.palInfo->data); currentBasePalette += BULLETS.palInfo->count;2. move image across screen by updating the x position.
//bullets for(i = 0; i < NUMBULLETS; i++) { if(bullets[i].alive)//player one { //move bullet bullets[i].y += bullets[i].yVel; //pictureSetPos(&bullets[i].pic, bullets[i].x, bullets[i].y); pictureMove(&bullets[i].pic,bullets[i].xVel, bullets[i].yVel); bullets[i].quadrant = ReturnQuadrant(bullets[i].x, bullets[i].y); //check for off screen if(CheckOffScreen(bullets[i].x, bullets[i].y, 1, 4)) { bullets[i].alive = 0; bullets[i].quadrant = 10; pictureHide(&bullets[i].pic); } } }3. check for collisions with other objects.
for(i = 0; i < NUMBULLETS; i++)//check each bullet for player one { if(bullets[i].alive)// && invaders[h].quadrant == bullets[i].quadrant)//check quadrant { //fixPrintf(2,8 + i,FIX_PAL,FIX_BANK,"IQ: %2d, BQ %2d ", invaders[h].quadrant, bullets[i].quadrant); // check for collision if(checkPointCollision(invaders[h].x, invaders[h].y, 12, bullets[i].x, bullets[i].y) ) { //remove bullet and invaders bullets[i].alive = 0; bullets[i].quadrant = 10; pictureSetPos(&bullets[i].pic, 330, 0); pictureHide(&bullets[i].pic); invaders[h].alive = 0; invaders[h].remove = 1; score++; moveTime-=2; enemiesKilled++; aSpriteSetPos(&invaders[h].spr, 330, 0); aSpriteAnimate(&invaders[h].spr); aSpriteHide(&invaders[h].spr); fixPrintf(4,2,FIX_PAL,FIX_BANK,"Score: %2d", score); } } }
This is code from my current game.
avatar

5

These codes are very useful to me.

It's hard for me to have no code examples.




I will continue. You helped me. Thank you.couple
avatar