You are not logged in.
Lost Password?


Register To Post



 Bottom   Previous Topic   Next Topic

#31
Re: .C into .VB
Posted on: 2009/4/12 0:19
PVB Elite
Joined 2003/7/25
USA
1507 Posts
PVBCC 1stCoderContributor#3 PosterHOTY09 EntryLong Time User (15 Years) App CoderPVBCC 2010 EntryPVBCC 2013 Entry
Very cool! About the start press problem, you can fix that by doing while(vbReadPad()&K_STA); after the while(!(vbReadPad()&K_STA)){}. That will cause it to wait until the button is released.

The other suggestion (doesn't matter too much in this case, but good programming practice) is to change the while(!(vbReadPad()&K_ANY)){} and K_STA loops to do the vbTextOut and other things outside the loop, then just wait with while(!(vbReadPad()&K_ANY)); . The way you're doing it now, you're redrawing the same text over and over, when you just need to draw it once and wait. I see you also have multiple vbDisplayShow()s... that's unnecessary, and definitely doesn't need to be done in the loop.

For it to keep moving instead of changing the sub's position directly with the keypad, increment/decrement it's position with a variable that you change with the keypad. Something like this:

while(1)
{
    if(
vbReadPad()&(K_LD)) vert=1;
    if(
vbReadPad()&(K_LU)) vert=-1;
    if(
vbReadPad()&(K_LL)) horz=-1;
    if(
vbReadPad()&(K_LR)) horz=1;

    
xpos+=horz;
    
ypos+=vert;

    
vbSetWorld(31WRLD_LON00000000);
    
vbSetWorld(30WRLD_LONxpos0ypos000384224);
    
vbSetWorld(29WRLD_END00000000);

    
vbWaitFrame(1);
}


Of course this will cause it to always move... to make it to press right to start moving right, then left to stop, then left again to start going left, do something like:

if(vbReadPad()&(K_LD)) vert++;
    if (
vert>1vert=1;
    if(
vbReadPad()&(K_LD)) vert--;
    if (
vert<-1vert=-1;


Then you could modify that to have acceleration and deceleration based on how long they hold the button by making it clip at +/- 2 or 3, etc with if (vert>3) vert=3; Of course you'll also need to make sure it doesn't go off the screen, but that can be part of the collision detection that I'm sure you're planning on doing.

Nice work so far... keep it up!

DogP
Top

#32
Re: .C into .VB
Posted on: 2009/4/12 0:49
PVB Elite
Joined 2008/4/26
USA
937 Posts
CoderContributorTop10 PosterHOTY09 3rdLong Time User (11 Years) PVBCC 2010 EntryPVBCC 2013 Entry
Thank you!
In case you're wondering where I'm going with all this, you can visit the original Atari 2600 version of GoSub here. To download it, just click on the little Pac-Man symbol on the right and then play it with either the Stella or Z26 emulators.

Posted is what I have so far with the VB version of the game.

Attach file:


vb gosube.VB Size: 64.00 KB; Hits: 180
c gosube.c Size: 2.45 KB; Hits: 170
Top

#33
Re: .C into .VB
Posted on: 2009/4/12 4:14
PVB Elite
Joined 2008/4/26
USA
937 Posts
CoderContributorTop10 PosterHOTY09 3rdLong Time User (11 Years) PVBCC 2010 EntryPVBCC 2013 Entry
Two new problems.
#1 - In the main game, I want to display both the level # and # of lives. But when I go and type in "LEVEL" and "LIVES", the text moves along with the submarine! How do I stop this? Also, I put in two new variables, "lives" and "level". How do I display them after "LEVEL" and "LIVES", respectively?

Attach file:


c gosube.c Size: 1.79 KB; Hits: 169
Top

#34
Re: .C into .VB
Posted on: 2009/4/12 8:32
PVB Elite
Joined 2003/7/25
USA
1507 Posts
PVBCC 1stCoderContributor#3 PosterHOTY09 EntryLong Time User (15 Years) App CoderPVBCC 2010 EntryPVBCC 2013 Entry
I haven't tried compiling any of this code, but I think this is probably what you want to do. For the first problem, you want to have the text output to a different BGMap. You do that by ORing the BGMap number in the second argument of vbSetWorld(), then change the vbTextOut to output to BGMap 1 like:


vbSetWorld
(30WRLD_ON|1000000384224);

vbTextOut(117,"IMPORTANT:");


For the second question, do you have a itoa() function in your libgccvb.h? If so, that's what you want to use. If not, I'd suggest getting it (should be able to find one in some sample code around here), but realize it's not perfect. A simple way to do it would also be:


char level_str
[3];
char lives_str[3];

//null terminate string
level_str[2]=0;
lives_str[2]=0;

level_str[0]=(level/10)+'0';
level_str[1]=(level%10)+'0';
lives_str[0]=(lives/10)+'0';
lives_str[1]=(lives%10)+'0';

vbTextOut(147,level_str);
vbTextOut(157,lives_str);


Don't forget all variables need to be declared before any code, so the char lines need to be up by your int vert=.... and the other code can be done in your main loop, but should only need to be done whenever the player loses a life or goes to the next level. This code would assume that the level and lives are never higher than 99 (and always display 2 digits).

Also, any reason you only want to play with the left eye? ;) You should change the WRLD_LON to WRLD_ON (or WRLD_LON|WRLD_RON). That will make it display to both eyes.

DogP
Top

#35
Re: .C into .VB
Posted on: 2009/4/12 9:35
PVB Elite
Joined 2008/4/26
USA
937 Posts
CoderContributorTop10 PosterHOTY09 3rdLong Time User (11 Years) PVBCC 2010 EntryPVBCC 2013 Entry
It worked, but it shows the first character in the character map for the small submarine in a pattern. How do i get rid of that?

Attach file:


c gosube.c Size: 2.06 KB; Hits: 183

png  0gosubdots.PNG (3.29 KB)
768_49e199bf9e543.png 384X224 px
Top

#36
Re: .C into .VB
Posted on: 2009/4/12 9:45
PVB Elite
Joined 2003/7/25
USA
1507 Posts
PVBCC 1stCoderContributor#3 PosterHOTY09 EntryLong Time User (15 Years) App CoderPVBCC 2010 EntryPVBCC 2013 Entry
Oh... you should clear your BGMap(1)... similar to the copymem((void*)BGMap(0)... that you used for creating your graphics, you need to set the other BGMap to be all blank. You can do that with setmem((void*)BGMap(1), 255, 1024*16); . I put 255 in there assuming that char 255 in your charseg is an all blank character. If not, go into VIDE and find the index of a blank character and put that number in.

DogP
Top

#37
Re: .C into .VB
Posted on: 2009/4/12 9:52
PVB Elite
Joined 2008/4/26
USA
937 Posts
CoderContributorTop10 PosterHOTY09 3rdLong Time User (11 Years) PVBCC 2010 EntryPVBCC 2013 Entry
Success!

Attach file:


vb gosube.VB Size: 64.00 KB; Hits: 210
c gosube.c Size: 2.10 KB; Hits: 191
Top

#38
Re: .C into .VB
Posted on: 2009/4/12 22:17
PVB Elite
Joined 2008/4/26
USA
937 Posts
CoderContributorTop10 PosterHOTY09 3rdLong Time User (11 Years) PVBCC 2010 EntryPVBCC 2013 Entry
There's nothing wrong, but the next thing I'd like to do is add a maze for the sub to navigate through (with an outlined border around the edges of the screen.) What would be the best way to do this? I'd like, at the least, 25 different mazes (which I'd design.) I just would like blocks to put in various places to form the mazes, if at all possible. Would they be solid blocks, or can they have designs on them? I'd like to design them as coral reefs, like in the water levels of SMB1 for the NES. But if they can be solid blocks, I wouldn't mind. I know this can probably be done, as VUE Snake proves.

EDIT: Here's a rough mock-up of what I'm imagining.

Attach file:



png  0gosubmockuplevel1.PNG (8.03 KB)
768_49e25795aa38c.png 384X223 px
Edited by VirtualChris on 2009/4/12 23:05
Top

#39
Re: .C into .VB
Posted on: 2009/4/13 2:34
PVB Elite
Joined 2008/4/26
USA
937 Posts
CoderContributorTop10 PosterHOTY09 3rdLong Time User (11 Years) PVBCC 2010 EntryPVBCC 2013 Entry
A little error that needs to be fixed.
I'm trying to put the treasure map in the game, but it comes out instead of the picture I want, it's a broken picture of the submarine. How do I make it so it's the treasure map instead of the broken sub?

Attach file:


h treasurechar.h Size: 47.98 KB; Hits: 182
h treasuremap.h Size: 53.00 KB; Hits: 147
c gosube.c Size: 2.32 KB; Hits: 159

png  0brokensub.PNG (2.82 KB)
768_49e28880cef5e.png 384X224 px
Top

#40
Re: .C into .VB
Posted on: 2009/4/13 3:45
PVB Elite
Joined 2003/7/25
USA
1507 Posts
PVBCC 1stCoderContributor#3 PosterHOTY09 EntryLong Time User (15 Years) App CoderPVBCC 2010 EntryPVBCC 2013 Entry
I see you're copying the chars to Charseg 2... when you exported the map, did you select that the chars will be in Charseg 2? You need to make sure you install DanB's VIDE export plugin that was mentioned earlier in the thread if you haven't already.

This will make a popup window come up when you click export to .h on the charmap. In that window, you want to select charseg 2. You could also put the treasure graphics in the same image as the rest of your game graphics, and just select it with vbSetWorld(29, WRLD_ON|2, xpos, 0, ypos, X_POS_IN_GFX, 0, Y_POS_IN_GFX, WIDTH, HEIGHT);, which cuts out a chunk WIDTH wide and HEIGHT high starting at X_POS_IN_GFX, Y_POS_IN_GFX in your graphics, and places it at xpos and ypos.

If nobody answers your question about creating the level, I'll try to answer tomorrow night, but I'm pretty busy tonight and don't have time for a lengthy post.

DogP
Top

 Top   Previous Topic   Next Topic


Register To Post