I was trying to write some code for my Gameboy with GBDK, and it errored

This is a discussion on I was trying to write some code for my Gameboy with GBDK, and it errored within the Game Programming forums, part of the General Programming Boards category; #include <gb/gb.h> #include <gb/drawing.h> UBYTE ship[10] = { {0, 0} {2, 1} {1, 1} {2, 1} {3, 1} {1, 2} ...

  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    14

    Unhappy I was trying to write some code for my Gameboy with GBDK, and it errored

    #include <gb/gb.h>
    #include <gb/drawing.h>




    UBYTE ship[10] =
    {
    {0, 0}
    {2, 1}
    {1, 1}
    {2, 1}
    {3, 1}
    {1, 2}
    {2, 2}
    {3, 2}
    {4, 2}
    {0, 3}
    }

    void main()
    {

    int x, y;
    for (x = 0; x < 9; x++)
    {
    color(BLACK, WHITE, SOLID);
    plot_point(ship[x][0], ship[x][1]);
    }

    }


    says there was a parse error before zero on line 10, and that code was not generated for ship because of previous errors at line 24. This is all in C, and again, I'm using the GBDK for this.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Are we counting blank lines to get to line 10? I.e., is the error on the line
    Code:
    {0,0}
    ? I'm not familiar with GBDK, but I'm guessing UBYTE just stands for "unsigned byte", which would mean each of those lines needs to be just a single number. (EDIT: The documentation I found online at belial.blarzwurst.de/gb/gbdk-doc.pdf would seem to agree. Not that that documentation looks like much, mind.)
    Last edited by tabstop; 12-05-2010 at 09:06 PM.

  3. #3
    Registered User
    Join Date
    Dec 2010
    Posts
    14

    Angry This is confuzzling

    No...see, I was trying to make this plot each of those vector locations. I had the for loop run throuh each position, then plot a point based on the first and second values in the array. But I don't understand the error D=

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    You seem to think that UBYTE and (0,0) are somehow even remotely similar. It would appear they are not. If you want an array of points, you should choose a data type that is a point. The easy way (without looking too much into what fancy data types, if any, this DK offers) would be to make a two-dimensional array:
    Code:
    UBYTE ship[10][2] =
    and then you would have all the numbers you desire.

    (EDIT: Oh, and if there was some sort of point-like data type -- let's call it UPOINT just as an example -- then you could declare
    Code:
    UPOINT ship[10] =
    but would have to reference at the end using dot notation, i.e., ship[10].x for the x-coordinate.)
    Last edited by tabstop; 12-05-2010 at 09:30 PM.

  5. #5
    Registered User
    Join Date
    Dec 2010
    Posts
    14

    Smile

    Quote Originally Posted by tabstop View Post
    You seem to think that UBYTE and (0,0) are somehow even remotely similar. It would appear they are not. If you want an array of points, you should choose a data type that is a point. The easy way (without looking too much into what fancy data types, if any, this DK offers) would be to make a two-dimensional array:
    Code:
    UBYTE ship[10][2] =
    and then you would have all the numbers you desire.

    (EDIT: Oh, and if there was some sort of point-like data type -- let's call it UPOINT just as an example -- then you could declare
    Code:
    UPOINT ship[10] =
    but would have to reference at the end using dot notation, i.e., ship[10].x for the x-coordinate.)
    UBYTE is one of the standard, low memory usage data types the DK offers. It's the most common one too. Anyway, yeah, I was just trying to make an array that I could store the X and Y of each point. The plot method just takes two ints in the form of the DK'S data types, plus some settings. Thanks, I'll test it tomorrow!

  6. #6
    Registered User
    Join Date
    Dec 2010
    Posts
    14

    Question A friend told me I forgot commas, which I did...

    #include <gb/gb.h>
    #include <gb/drawing.h>




    UBYTE ship[10] =
    {
    {0, 0},
    {2, 1},
    {1, 1},
    {2, 1},
    {3, 1},
    {1, 2},
    {2, 2},
    {3, 2},
    {4, 2},
    {0, 3}
    }

    void main()
    {

    int x, y, i;
    for (i = 0; i < 9; i++)
    {
    color(BLACK, WHITE, SOLID);
    plot_point(ship[x][0], ship[x][1]);
    }

    }

    Now the only error I get is at line 21. It says there was a parse error before void, but everything looks alright....

  7. #7
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    The obvious is now the missing semicolon at the end of the declaration.

  8. #8
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    Not to mention, reading the forum intro threads and learning how to use [code][/code] tags.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  9. #9
    Registered User
    Join Date
    Dec 2010
    Posts
    14

    Smile Sorry, it was midnight when I was posting

    Sorry guys. Thanks for putting up with me in my worst.

Popular pages Recent additions subscribe to a feed

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21