Original Post

Announcing the beginning of work on GoSub 2. Improvements over the original are:
+I am going to add an octopus chasing you. To fire a torpedo in the direction you’re going, press A.
+I also plan to put in more than 32 levels this time. These levels include an in and out, and no treasure. Your search is for the big huge treasure chest I plan to put in at the end.
Right now, all I have is a title screen. There are two different animations, please watch both of them, and I remind you these are placeholder graphics, and may not be used in the final version (especially the torpedo sprite!)

Attachments:
66 Replies

Oh, didn’t know that, what a nice feature! I will try it out some day.

Oh wow, those glasses look so much more awesome and durable than those standard issue cardboard ones I have. I bought ’em too.

Changing the color scheme can be done on the command line too, by the way. It’s all explained in the Mednafen thread on here somewhere.

I’ve been trying to make the game be in 3D but I am having some troubles. It doesn’t matter when the ship is in the foreground or the background, it still hits the first foreground bar. (When the sub is in the background, it shouldn’t hit the foreground bar because it’s not in the sub’s dimension) I think it has something to do with lines 34-37, but I am not sure. I have moved the background maze to world 2 so this has removed the underwater background in favor of an actual 3D game. So if someone could look through my code and tell me what I’m doing wrong with the collision detection, I’d very much appreciate it.

Attachments:

Here’s your problem:

Change

HWORD getBGMapChar(bgmap, x, y)
{ 
    return (BGMM[(0x1000) + (y * 64) + x]&0x7FF);  
}

to

HWORD getBGMapChar(bgmap, x, y)
{ 
    return (BGMM[bgmap*(0x1000) + (y * 64) + x]&0x7FF);  
}

That worked for the foreground, but now the background level has no collision detection.

Now, I know you’ve been picked on before for your coding style, but your code is still very hard to read (and thus it will take longer for us to help you find errors in it).

The worst thing is that you tend to repeat the same code over and over again, which is both redundant and inefficient.

For example, stuff like this:

// bottom front
if ((d==0) && (getBGMapChar(1, (xpos/8)+0, (ypos/8)+2)==512)) xpos=20, ypos=180, gamesubdir=0, lives=lives-1, b=1, torpedodir=0;
if ((d==0) && (getBGMapChar(1, (xpos/8)+1, (ypos/8)+2)==512)) xpos=20, ypos=180, gamesubdir=0, lives=lives-1, b=1, torpedodir=0;
if ((d==0) && (getBGMapChar(1, (xpos/8)+2, (ypos/8)+2)==512)) xpos=20, ypos=180, gamesubdir=0, lives=lives-1, b=1, torpedodir=0;
if ((d==0) && (getBGMapChar(1, (xpos/8)+3, (ypos/8)+2)==512)) xpos=20, ypos=180, gamesubdir=0, lives=lives-1, b=1, torpedodir=0;
if ((d==0) && (getBGMapChar(1, (xpos/8)+4, (ypos/8)+2)==512)) xpos=20, ypos=180, gamesubdir=0, lives=lives-1, b=1, torpedodir=0;

is a big no-no and should instead be written like:

// bottom front
if (d == 0) { 
  int i;
  for (i = 0; i < 5; i++) {
    if(getBGMapChar(1, (xpos/8)+i, (ypos/8)+2) == 512) {
      xpos = 20;
      ypos = 180;
      gamesubdir = 0;
      lives--;
      b = 1;
      torpedodir = 0;
      break;
    }
  }
}

which does the exact same thing but is alot cleaner to read. (And also faster for the poor VB to execute)

Please try to make changes like that 🙁

The difference between the my example and yours is I understand mine. Of course, I am still learning C, and why I code the way I do is because I have a lot more experience in Basic than I do in C. But yeah, I will do my best to try and clean up the code to the best of my abilities with what knowledge of C (which is little) I know.

VirtualChris wrote:
That worked for the foreground, but now the background level has no collision detection.

I see it now…
It’s because you’re using a different coral char for the background than the foreground (different charsegs containing identical graphics = waste!).

Fix it by either have both bgmap1 and bgmap2 use the same charseg (preferred, since it’s really the same graphic anyway), OR check for collision with char 1024 instead of 512 when the sub is in the background level.

I now have a new problem: The sub won’t move. Before you groan because you have to look through my code, I’ll remind you I tried to fix it up as best I could. If it’s not enough and I need to do it some more, I apologize.

Attachments:

I got the sub moving again, and I have a question: How do I make two things share the same character? I mean, I type

	copymem((void*)CharSeg1, (void*)CORAL, 256*16);

for one, and

	copymem((void*)CharSeg2, (void*)CORAL, 256*16);

for the other. How would I make them share?

Attachments:

OK, I figured this out! I just had to tweak DanB’s code a little to make it do what I wanted it to do. Anyway, to switch between foreground and background, press A. To make it easier to tell which dimension you are, use Mednafen because it has the red and blue lines. Hopefully this will actually look like two dimensions on a real Virtual Boy. If possible and you have both a Flash boy and a digital camera, take a picture of it running. I want to make sure I like what I’m doing here.

Attachments:

The difference between the my example and yours is I understand mine.

Then, before you continue doing anything at all, I suggest you learn how a for loop works. It’s really useful, really powerful, and you’ll be using it all the time to avoid using repeating code! 🙂

VirtualChris wrote:
I got the sub moving again, and I have a question: How do I make two things share the same character? I mean, I type

	copymem((void*)CharSeg1, (void*)CORAL, 256*16);

for one, and

	copymem((void*)CharSeg2, (void*)CORAL, 256*16);

for the other. How would I make them share?

You make them share simply by ONLY copying the CORAL to Charseg1, and then you re-export the maps from VIDE, choosing “use charseg #1” for both of them.

I tried it on the flashboy, and it works fine. Maybe just a little slower than in mednafen.

The 3D effect is alright, but here are some suggestions to make it better:

Draw a slightly smaller version of the sub that you switch to when it’s in the back layer. That will help with the illusion that it’s further away.

Right now you use depth 0 for the foreground and 2 for the background. Keep 2 for the background, but change the foreground to -2 for a deeper effect.

And put the world with the sub in between the maze worlds. Right now, when you pass behind a wall, it looks like you go in front of it.

  • This reply was modified 13 years, 10 months ago by DanB.
Attachments:

Changed the look of the sub. Also made it, the octopus, and the torpedo smaller when they’re in the background. Also shifted the worlds around a little like DanB suggested.

Attachments:

VirtualChris wrote:
…why I code the way I do is because I have a lot more experience in Basic than I do in C.

Well, since BASIC also has “for” loops, that’s a pretty lame excuse 😉

But yeah, I will do my best to try and clean up the code to the best of my abilities with what knowledge of C (which is little) I know.

That’s a good start, but, rather than restrict your code’s improvement to the C you already know, why not learn more about C first? You should be able to find a C tutorial aimed specifically toward BASIC programmers (although BASIC-related stuff is getting harder to find every day…). Even if you can’t, just get a good reference and read through it a few times. Then, when you program, think about what would be the best solution to a given problem (hint: it probably doesn’t involve writing the same few lines of code fifteen times with a few values changed ;-)).

BTW, good job on what you’ve done so far. I think you should enter it in the compo, though. It’s already further along than my entry 🙁

The BASIC I’m used to is batari Basic, which is a type of Basic for the Atari 2600. I don’t really know about for loops yet because I’m confused about where to put the “next.” Anyway, if I get it done by November 1 (which now I’m thinking I will), I’ll put it in the contest.

Was playing with the title screen a little and was wondering if there was some type of programming that can do what I’ve tried to do for the title screen being in 3D. (By the way, I’ve also added a third level.)

Attachments:

VirtualChris wrote:
Was playing with the title screen a little and was wondering if there was some type of programming that can do what I’ve tried to do for the title screen being in 3D.

When you have two different images that each should only be visible to one eye (the 3D logo in two different angles), you do like this:

Instead of using WRLD_ON, that displays the world to both eyes, do:

vbSetWorld(31, WRLD_LON, x, x, x, x, x, x, x, x); //image for left eye only
vbSetWorld(30, WRLD_RON, x, x, x, x, x, x, x, x); //image for right eye only

Place the two worlds right in front of each other, and you have your 3D effect.

Also, I think you should put back the scrolling wavy background in the levels. You can still have it even when the levels are 3D, just put it even further back, at depth 10 or so…

Here’s another pro tip 😉

You should be able to fit both the front and back mazes for each level over and under each other in the same map. That way you only need to use one map per level. (same technique as with the sub/octo/torpedo).

Then, have the back maze use a darker red coral than the front for an even better 3D effect.

 

Write a reply

You must be logged in to reply to this topic.