How do I turn a C file into something to run in a Virtual Boy emulator? I was fiddling around with Notepad making a C file and I downloaded gccvb and VIDE, but I can’t find anything that would do this?
- This topic was modified 15 years, 5 months ago by VirtualChris.
Why does this work
if (getBGMapChar(1, (xpos/8)+1, (ypos/8)+1)==512) level=level-1, xpos=10, ypos=160, horz=0, vert=0;
while this doesn’t?
if (getBGMapChar(1, (xpos/8)+1, (ypos/8)+1)==512)||(getBGMapChar(1, (xpos/8)+2, (ypos/8)+1)==512)||(getBGMapChar(1, (xpos/8)+1, (ypos/8)+2)==512)||(getBGMapChar(1, (xpos/8)+2, (ypos/8)+2)==512) level=level-1, xpos=10, ypos=160, horz=0, vert=0;
I’m somewhat getting the hang of it, as you can see from my VB rom code below.
Attachments:
You need to fix your ()’s, like:
if ((getBGMapChar(1, (xpos/8)+1, (ypos/8)+1)==512)||(getBGMapChar(1, (xpos/8)+2, (ypos/8)+1)==512)||(getBGMapChar(1, (xpos/8)+1, (ypos/8)+2)==512)||(getBGMapChar(1, (xpos/8)+2, (ypos/8)+2)==512)) level=level-1, xpos=10, ypos=160, horz=0, vert=0;
DogP
I got the collision detection working now, but it’s like a square. How would I go about not checking the empty space near the periscope?
- This reply was modified 15 years, 8 months ago by VirtualChris.
I redesigned the submarine sprite so it takes up less blank space. (I know, I can’t really design good-looking sprites like this.) And the code I have now (which is the code from the last post) seems to have a problem, if you look at the picture. How do I go about fixing this?
Attachments:
Your submarine is 3×3 Chars now, right? With the top left and top right not being part of the submarine, like:
080
888
888
where 8’s are part of the submarine and 0’s are not.
You need to expand the collision detection code, right now you’re only checking 2×2 Chars from the top left, as if your submarine looked like this:
880
880
000
(Hint: if(getBGMapChar(1, (xpos/8)+1, (ypos/8)+1)==512) checks the top left Char)
I figured it out.
Now, how do I check the collision on the treasure?
EDITED the sourcecode/VB ROM
- This reply was modified 15 years, 8 months ago by VirtualChris.
- This reply was modified 15 years, 8 months ago by VirtualChris.
Attachments:
well done! now, for the treasure chest, you can write a small function which in some way compares the coordinates of the chest (treasurexpos, treasureypos) to those of the sub (xpos, ypos), keeping the width and height of the sub and chest in mind. I am sure you can figure that out as well. 🙂
I would just check the X and Y distances from the center of the sub to the center of the chest.
if ((abs(treasurexpos - xpos) < sub_width) && (abs(treasureypos - ypos) < sub_height)) { you_win = true; }
(The function returning the absolute value of a number is left as an exercise for the reader. ;-))
P.S. I could make an attempt at a 3D sub sprite for you.
Thank you for the code. If you could attempt to make a 3D sprite, I’d really appreciate it.
Attachments:
Added a second level after you complete the first one.
Attachments:
It is very hard to make a stereoscopic image that small with such a limited palette!
I would gladly trade sixteen Worlds and 512 Chars for one more bit of color depth!
Anyway, here’s what I have so far. It’s quite ugly, but maybe you can use it for a skeleton to build on, or something…
The left image is on the right (I’m in the “cross-eyed” camp when it comes to free-viewing ;-))
Attachments:
Why is it that when I put in this code, once level 1 is completed, it skips level 2 and goes to level 3?
// treasure collision if ((abs(treasurexpos - xpos) < sub_width-10) && (abs(treasureypos - ypos) < (sub_height-8))) { level=level+1, xpos=16, ypos=152, horz=0, vert=0; if (level=2) copymem((void*)BGMap(1), (void*)LEVEL2MAP, 256*16); if (level=3) copymem((void*)BGMap(1), (void*)LEVEL3MAP, 256*16); }
It is because of your if statements. Instead of:
if (level=2) …
if (level=3) …
they should be:
if (level==2) …
if (level==3) …
yep, “=” is an assigment, while “==” is a comparator.
BTW, that sub looks amazing, RunnerPack!
Here’s what I will do from now until the game’s level designs are finished. Any update regarding a new level (like this update), it will be the first level in the ROM (so you can all play it.), then after you complete that level, it will go to level 2. So the first level in this ROM will actually be level 4 even though it says “LEVEL 01” at the top. Also, I have a question. How do I make it so it goes to the title screen after all your lives are lost? (after you die when you don’t complete the maze when it says “LIVES 00”. I’d like there to be four attempts at completing each level.)
Attachments:
There’s a couple ways you can do it… probably the least ugly way to do it would be to put a while(1) loop starting at the title screen, all the way to the end (before the } at the end of main() ). Then change the existing while(1) around your game loop to while (lives>=0).
The other way (which isn’t exactly good programming style, but is easy) would be to put inside your game loop an if(lives<0) goto start; and put start: before your title screen. Don't forget to move lives=3; and probably level=1; to somewhere before the game starts again, or it'll keep resetting to the title screen (since lives will still be less than 0).
DogP
This thread is turning into a full step by step tutorial with example code on how to make a game 😀
That’s good, because we need more VB homebrew games!
Added a level. Game is now 256k.
Attachments: