Original Post

hello, I’m programming a new game based on characters from old Spanish game called “Captain Sevilla ‘”, I know nothing of programming in C and I need your help.(what little I know is thanks to your comments and demos)

when include in the code new documents. h , the screen appears black. Why?

I leave the code works. I want to include the character and move it for the background (for the moment,jejeje)

thank you very much for your time!!

my english is very bad, sorry!!

  • This topic was modified 14 years, 1 month ago by rubengar.
  • This topic was modified 14 years, 1 month ago by rubengar.
  • This topic was modified 14 years, 1 month ago by rubengar.
72 Replies

RunnerPack wrote:

rubengar wrote:

hello, your code I had seen him days ago, but I did not work.

Can you post what you did? Maybe I can see your error (or, more likely, my error ;-)).

I hope you can help me. you could include in my code your jump code??, maybe something I did wrong
🙁

Well, I really don’t have time right now, and without the graphics I can’t recompile to test. Also, I think it would be a good learning experience for you to get it working yourself. You’re doing very well so far for a “non-programmer” 😀

Maybe you should just forget my code, and try to understand and then implement the algorithm yourself. Maybe a physics text-book would help?

the glitch I’ll fix it when the char animation ends!!

thank you very much!!!!

You’re very welcome.

this night I write new jump code code and fail, but I looked back your code and finally works, thank you very I will include you and other friends of the forum in the credits of the game!! (when I finish the game,jejeje) :thumpup:

rubengar wrote:

this night I write new jump code code and fail, but I looked back your code and finally works, thank you very I will include you and other friends of the forum in the credits of the game!! (when I finish the game,jejeje) :thumpup:

Hey, way to go! Can’t wait to see the new version (and the complete game, of course). I’m honored to have my name
connected to such an interesting game project, although I wouldn’t mind getting one of those expensive hams, too 😉

What’s the next thing you plan to work on, now that jumping works?

RunnerPack wrote:

rubengar wrote:

this night I write new jump code code and fail, but I looked back your code and finally works, thank you very I will include you and other friends of the forum in the credits of the game!! (when I finish the game,jejeje) :thumpup:

Hey, way to go! Can’t wait to see the new version (and the complete game, of course). I’m honored to have my name
connected to such an interesting game project, although I wouldn’t mind getting one of those expensive hams, too 😉

What’s the next thing you plan to work on, now that jumping works?

ohh thanks!!

the following is the collision detection, new enemies, and the new backgrounds(in 3d), etc……I make a very elaborate game. very working hours!!!!!!!!!!!

I leave an update of my demo!!!

A button for jump!!

Attachments:

rubengar wrote:

RunnerPack wrote:

rubengar wrote:

this night I write new jump code code and fail, but I looked back your code and finally works, thank you very I will include you and other friends of the forum in the credits of the game!! (when I finish the game,jejeje) :thumpup:

Hey, way to go! Can’t wait to see the new version (and the complete game, of course). I’m honored to have my name
connected to such an interesting game project, although I wouldn’t mind getting one of those expensive hams, too 😉

What’s the next thing you plan to work on, now that jumping works?

ohh thanks!!

the following is the collision detection, new enemies, and the new backgrounds(in 3d), etc……I make a very elaborate game. very working hours!!!!!!!!!!!

I leave an update of my demo!!!

A button for jump!!

I´m a idiot, the previous file is not correct 😛

when I get home I’ll post the correct file, sorry!!!!!!!

Hi I leave the new file!!

One question, when I load a new background (the backgrounds go one after another if the character progresses,
are not independent levels)
example:

if ((marix>383) && (lives>0)) level=level+1;

I want to eliminate the enemies of the previous background, how?

the world of enemies is:

vbSetWorld(27, WRLD_ON|3, bakalax, 0, bakalay, bframe*24, 0, 96, 24, 48);//enemie1

vbSetWorld(26, WRLD_ON|3, dbakalax, 0, dbakalay, dbframe*24, 0, 96, 24, 48);//enemie2

copymem((void*)BGMap(3), (void*)FONTMAP, 256*16);//font and enemies

thanks!!!!

Attachments:

rubengar wrote:
Hi I leave the new file!!

One question, when I load a new background (the backgrounds go one after another if the character progresses,
are not independent levels)
example:

if ((marix>383) && (lives>0)) level=level+1;

I want to eliminate the enemies of the previous background, how?

the world of enemies is:

vbSetWorld(27, WRLD_ON|3, bakalax, 0, bakalay, bframe*24, 0, 96, 24, 48);//enemie1

vbSetWorld(26, WRLD_ON|3, dbakalax, 0, dbakalay, dbframe*24, 0, 96, 24, 48);//enemie2

copymem((void*)BGMap(3), (void*)FONTMAP, 256*16);//font and enemies

thanks!!!!

Woot! El capitán puede saltaaaaaar! 😉

If you want to stop displaying a World, you just have to leave the “WRLD_ON” (or WRLD_LON or WRLD_RON) part out of the “flags” part of the header. If you’re calling vbSetWorld() every frame to update the position of the enemies (which is a little wasteful of cycles, but probably not a big deal in this particular game) you can just keep the flags part in a variable or structure, and change it at will, like this:


u16 enemy1header = WRLD_ON | 3;

.
.
.

// Update inside the loop
vbSetWorld(27, enemy1header, bakalax, 0, bakalay, bframe*24, 0, 96, 24, 48); // Enemy 1

.
.
.

// Disable
enemy1header = 3;

// Enable
enemy1header = WRLD_ON | 3;

Otherwise, you can use the WA structure array in world.h to just change the flags, like this:

// Setup
vbSetWorld(27, 3, bakalax, 0, bakalay, bframe*24, 0, 96, 24, 48); // Enemy 1

.
.
.

// Disable
WA[27].head &= ~(WRLD_ON);

// Enable
WA[27].head |= WRLD_ON;

// Move
WA[27].gx = bakalax;
WA[27].gy = bakalay;

// Animate
WA[27].mx = bframe * 24;

Note: the “~” inverts each bit of the argument.

RunnerPack wrote:

rubengar wrote:
Hi I leave the new file!!

One question, when I load a new background (the backgrounds go one after another if the character progresses,
are not independent levels)
example:

if ((marix>383) && (lives>0)) level=level+1;

I want to eliminate the enemies of the previous background, how?

the world of enemies is:

vbSetWorld(27, WRLD_ON|3, bakalax, 0, bakalay, bframe*24, 0, 96, 24, 48);//enemie1

vbSetWorld(26, WRLD_ON|3, dbakalax, 0, dbakalay, dbframe*24, 0, 96, 24, 48);//enemie2

copymem((void*)BGMap(3), (void*)FONTMAP, 256*16);//font and enemies

thanks!!!!

Woot! El capitán puede saltaaaaaar! 😉

If you want to stop displaying a World, you just have to leave the “WRLD_ON” (or WRLD_LON or WRLD_RON) part out of the “flags” part of the header. If you’re calling vbSetWorld() every frame to update the position of the enemies (which is a little wasteful of cycles, but probably not a big deal in this particular game) you can just keep the flags part in a variable or structure, and change it at will, like this:


u16 enemy1header = WRLD_ON | 3;

.
.
.

// Update inside the loop
vbSetWorld(27, enemy1header, bakalax, 0, bakalay, bframe*24, 0, 96, 24, 48); // Enemy 1

.
.
.

// Disable
enemy1header = 3;

// Enable
enemy1header = WRLD_ON | 3;

Otherwise, you can use the WA structure array in world.h to just change the flags, like this:

// Setup
vbSetWorld(27, 3, bakalax, 0, bakalay, bframe*24, 0, 96, 24, 48); // Enemy 1

.
.
.

// Disable
WA[27].head &= ~(WRLD_ON);

// Enable
WA[27].head |= WRLD_ON;

// Move
WA[27].gx = bakalax;
WA[27].gy = bakalay;

// Animate
WA[27].mx = bframe * 24;

Note: the “~” inverts each bit of the argument.

thanks for help me!!

hi! I need help again!! as I can do to make a flicker character ?? thanksss!!!!

rubengar wrote:
hi! I need help again!! as I can do to make a flicker character ?? thanksss!!!!

I see C tutorials but did not find an answer for blink font o blink character, I would be very grateful if you help me!! Capitan sevilla go on!!:)

rubengar wrote:
I see C tutorials but did not find an answer for blink font o blink character, I would be very grateful if you help me!! Capitan sevilla go on!!:)

Well, obviously, to make something blink, you just make it invisible periodically. It’s essentially the same as the animation you’ve already done, you just change the visibility of the “thing” instead of changing the picture.

Each Object and each World has a “visibility” bit for each screen. If you toggle these bits in sync with the screen refresh rate, the item in question will blink. If you just want a specific character (or “cell”) in a BGMap to blink, you’ll have to actually change the character pointed to by that cell (again, just like animation). If you want every instance of a given character to blink, you can actually change the pixels in it every frame. I would suggest keeping the two (or more) “versions” of the char and using copymem() (with alternating source pointers) to do the changing.

The main problem (which I think is also the problem with your/my/our 😉 jump code) is the “synchronizing to the screen refresh” part. vbWaitFrame() (no matter which version you have) is just not the answer for “production-quality” code. I’ve experimented with using the VIP interrupt and the “display” and “expansion” status registers, but the docs are quite confusing in this area (at least to me). The timer is also a possibility (see Fwirt’s demo code).

rubengar, if you upload your graphics, I’ll look at getting your project working with grit. It’d mean you’d be able to have all your graphics in a single file.

RunnerPack wrote:
I’ve experimented with using the VIP interrupt and the “display” and “expansion” status registers, but the docs are quite confusing in this area (at least to me).

No kidding… >:( The official Nintendo development manual talks about game frame timing in section 5-21-1. Apparently they intended you to use the refresh rate as the timer for your main loop, although I haven’t really had the time to get that figured out. However, the timer is pretty easy to understand and set to the correct speed for your game. Basically what I’m doing for main loop timing right now is setting up the timer before I get into the main loop, and then waiting for zero status every time I finish one iteration of my main loop. Something like this:

timer_freq(TIMER_100US);
timer_set(TIME_MS(15));
timer_enable(1);
for(;;) {
    timer_clearstat();

    // Insert main routine here

    while(!timer_getstat());
}

Note that I use getstat differently, as I modified my version of libgccvb to be more true to the hardware so that getstat returns 1 when the timer is 0. The timer takes a few more instructions to set up, but it will make your program a lot more reliable.

Flicker / display sync mini-demo:

int main()
{
  int count= 0;

  vbDisplayOn();
  vbDisplayShow();

  // main loop @ 50 Hz
  while(1)
  {
    // wait for the VIP to finish drawing
    while(!(VIP_REGS[REG_INTPND] & XPEND));
    // clear flag
    VIP_REGS[INTCLR]= XPEND;

    // read controller

    // do stuff		

    if((count%7)==0)
      VIP_REGS[BKCOL] ^= 3;  // flicker

    count++;
  }

  return 0;
}

Oops, fixed a typo:

    if((count&7)==0)
      VIP_REGS[BKCOL] ^= 3;  // flicker

thank you all for your answers!!! new demo coming soon!!

The captain sevilla continues forward, now it can shoot “morcillas radiactivas” to kill the enemies, and I have included a game over text when you die and a screen of introduction initially of level, and new enemies. I want to continue working with the new backgrounds before upload a new demo!!



  • This reply was modified 14 years ago by rubengar.
  • This reply was modified 14 years ago by rubengar.

Hello! I leave here a demo of the game in its current state, I work much still. The demo works ok in the mednafen and reality boy emulator, in the red dragon WORKS BAD!! Thanks!!

CONTROLS:

lef pad= move the character
A button= shoot “morcillas radiactivas”
B button= jump power “press more time the button to jump more”
start button= pause game

ICON:

take a “morcilla radiactiva” blink= one “morcilla” plus

Attachments:

rubengar wrote:

A button= shoot “morcillas radiactivas”
B button= jump power “press more time the button to jump more”

I think you got those swapped as “A” is the jump and “B” is “throw” (which is the “correct” way to do it ;-)).

The progress is definitely going well, but I would really like to look at the code so I can help fix the “moving forward aborts the jump” bug. It’s probably a side-effect of putting in tests for other buttons besides “A”.

I’m proud of you! 😀 Keep up the good work! :thumpup:

RunnerPack wrote:

rubengar wrote:

A button= shoot “morcillas radiactivas”
B button= jump power “press more time the button to jump more”

I think you got those swapped as “A” is the jump and “B” is “throw” (which is the “correct” way to do it ;-)).

The progress is definitely going well, but I would really like to look at the code so I can help fix the “moving forward aborts the jump” bug. It’s probably a side-effect of putting in tests for other buttons besides “A”.

I’m proud of you! 😀 Keep up the good work! :thumpup:

jejeje, sorry confused me to write!!

B button= shoot “morcillas radiactivas”
A button= jump power “press more time the button to jump more”

  • This reply was modified 14 years ago by rubengar.

rubengar wrote:

RunnerPack wrote:

rubengar wrote:

A button= shoot “morcillas radiactivas”
B button= jump power “press more time the button to jump more”

I think you got those swapped as “A” is the jump and “B” is “throw” (which is the “correct” way to do it ;-)).

The progress is definitely going well, but I would really like to look at the code so I can help fix the “moving forward aborts the jump” bug. It’s probably a side-effect of putting in tests for other buttons besides “A”.

I’m proud of you! 😀 Keep up the good work! :thumpup:

jejeje, sorry confused me to write!!

B button= shoot “morcillas radiactivas”
A button= jump power “press more time the button to jump more”

in my opinion jump is good, just hold the button down longer to jump higher

 

Write a reply

You must be logged in to reply to this topic.