- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
#include <gb/gb.h>
#include <stdio.h>
#include "racecars.h"
/*
RACECARS.C
Tile Source File.
Info:
Form : All tiles as one unit.
Format : Gameboy 4 color.
Compression : None.
Counter : None.
Tile size : 8 x 8
Tiles : 0 to 16
Palette colors : None.
SGB Palette : None.
CGB Palette : None.
Convert to metatiles : No.
This file was generated by GBTD v2.2
*/
/* Start of tile array. */
unsigned char Racecars[] =
{
0x7E,0x7E,0x42,0x5E,0xC3,0xD7,0xC3,0xDF,
0x42,0x52,0x7E,0x7E,0xC3,0xC3,0xC3,0xC3,
0x1C,0x1C,0x36,0x3E,0x62,0x7A,0x43,0x4B,
0x41,0x5D,0x7F,0x7F,0x55,0x55,0x77,0x77,
0x38,0x38,0x44,0xC6,0xAA,0xAA,0xAA,0xAA,
0xAA,0xAA,0x82,0x82,0x44,0xC6,0x38,0x38,
0x18,0x18,0x18,0x18,0x24,0x24,0x42,0x42,
0xFF,0xFF,0x00,0xC6,0x00,0xC6,0x00,0x00,
0x3C,0x3C,0x24,0xE7,0x24,0xE7,0x24,0x24,
0x24,0xE7,0x3C,0xFF,0x24,0x24,0x3C,0x3C,
0x18,0x18,0x24,0xE7,0x42,0xC3,0x42,0x42,
0x42,0x42,0x24,0x66,0x18,0x7E,0x00,0x00,
0xF2,0xF2,0x96,0x96,0xF2,0xF2,0x82,0x82,
0x8F,0x8F,0x00,0x00,0x00,0x00,0x00,0x00,
0xEE,0xEE,0x82,0x82,0x8E,0x8E,0x8B,0x8B,
0xEE,0xEE,0x00,0x00,0x00,0x00,0x00,0x00,
0xEE,0xEE,0x82,0x82,0x8E,0x8E,0x82,0x82,
0xEE,0xEE,0x00,0x00,0x00,0x00,0x00,0x00,
0xE2,0xE2,0x86,0x86,0x82,0x82,0x82,0x82,
0xE7,0xE7,0x00,0x00,0x00,0x00,0x00,0x00,
0xEA,0xEA,0x8A,0x8A,0x8E,0x8E,0x82,0x82,
0xE2,0xE2,0x00,0x00,0x00,0x00,0x00,0x00,
0xE7,0xE7,0x84,0x84,0x87,0x87,0x81,0x81,
0xE7,0xE7,0x00,0x00,0x00,0x00,0x00,0x00,
0xF7,0xF7,0x85,0x85,0x85,0x85,0xB5,0xB5,
0x95,0x95,0xF7,0xF7,0x00,0x00,0x00,0x00,
0x82,0x82,0x82,0x82,0x92,0x92,0x92,0x92,
0x92,0x92,0x92,0x92,0xFE,0xFE,0x00,0x00,
0xFF,0xFF,0x10,0x10,0x10,0x10,0x10,0x10,
0x10,0x10,0xFF,0xFF,0x00,0x00,0x00,0x00,
0x82,0x82,0xC2,0xC2,0xA2,0xA2,0x92,0x92,
0x8A,0x8A,0x86,0x86,0x82,0x82,0x00,0x00,
0x20,0x20,0x30,0x30,0x38,0x38,0x3C,0x3C,
0x20,0x20,0x20,0x20,0x20,0x20,0xFF,0xFF
};
/* End of RACECARS.C */
int main(void){ //starts the main function
int x,y,st,key,z; //define the integers x and y wich will be used to define the hero position, key will be used later
int x1,y1,st1;
int x2,y2,st2;
int x3,y3,st3;
x=20; //set x as 20
y=20; //set y as 20
st=0; //sprite type(1=closed 0=open)
z=0; //set z=0, z will be used for testing if its time to change sprite or not
set_sprite_data(0,76,Racecars); //set our sprite data
wait_vbl_done(); //wait for the visual blank to be done
set_sprite_tile(0,0); //set our tile 0 as the tile 0 of our tile data-pacman open
set_sprite_tile(1,1); //set our tile 1 as the 1st tile of our tile data-pacman closed
set_sprite_tile(2,2);
set_sprite_tile(3,3);
set_sprite_tile(4,4);
set_sprite_tile(5,5);
set_sprite_tile(6,6);
set_sprite_tile(7,7);
set_sprite_tile(8,8);
set_sprite_tile(9,9);
set_sprite_tile(10,10);
set_sprite_tile(11,11);
set_sprite_tile(12,12);
set_sprite_tile(13,13);
set_sprite_tile(14,14);
set_sprite_tile(15,15);
set_sprite_tile(16,16);
move_sprite(st,x,y);
#define MapSizeX 256;
#define MapSizeY 256;
UBYTE ScrollXCnt;
UBYTE ScrollYCnt;
BYTE SCXCnt;
BYTE SCYCnt;
UBYTE tempa, tempb;
UWORD Cnt;
Cnt = 0;
wait_vbl_done();
for(tempa = 0; tempa != 32; tempa++) {
set_bkg_tiles(0,tempa,32,tempa+1,TileMap[Cnt]);
Cnt = Cnt + MapSizeX;
}
if(joypad() & J_UP) ScrollUp();
if(joypad() & J_DOWN) ScrollDown();
if(joypad() & J_LEFT) ScrollLeft();
if(joypad() & J_RIGHT) ScrollRight();
wait_vbl_done();
scroll_bkg(x,y);
ScrollX++; or ScrollX--;
ScrollY++; or ScrollY--;
SCXCnt++; or SCXCnt++;
SCYCnt++; or SCYCnt--;
if(SCXCnt == 8) {
SCXCnt = 0;
Cnt = ScrollX / 8;
Cnt = Cnt + 20;
for(tempa = 0; tempa != 224; tempa++) {
set_bkg_tiles(0,tempa,1,tempa+1,TileMap[Cnt]);
Cnt = Cnt + MapSizeX;
}
}
if(SCXCnt == -8) {
SCXCnt = 0;
SCXCnt = 0;
Cnt = ScrollX / 8;
Cnt--;
for(tempa = 0; tempa != 224; tempa++) {
set_bkg_tiles(0,tempa,1,tempa+1,TileMap[Cnt]);
Cnt = Cnt + MapSizeX;
}
}
.
.
.
这是c代码
我运行提示并弹出以下错误。
Parse error before ubyte line 108
Parse error before scroll x
Parse error before scroll y
Parse error before scxCnt
Parse error before ScyCnt
Parse error before 32
最佳答案
您的问题是您必须在函数中间定义新变量。无论出于何种原因,GBDK 编译器都不允许这样做。 (这显然是 ANSI C/C89 标准的一部分)
您可以通过将 main()
的顶部从
int main(void){ //starts the main function
int x,y,st,key,z; //define the integers x and y wich will be used to define the hero position, key will be used later
int x1,y1,st1;
int x2,y2,st2;
int x3,y3,st3;
对此:
int main(void){ //starts the main function
int x,y,st,key,z; //define the integers x and y wich will be used to define the hero position, key will be used later
int x1,y1,st1;
int x2,y2,st2;
int x3,y3,st3;
//These variables are used later on.
UBYTE ScrollXCnt;
UBYTE ScrollYCnt;
BYTE SCXCnt;
BYTE SCYCnt;
UBYTE tempa, tempb;
UWORD Cnt;
或者,您可以将从这些变量开始的所有代码移动到另一个函数,然后这些变量将使用该函数进行声明,一切都会好起来的。
关于c - 我正在运行 gbdk 一个 gameboy 游戏制作程序,并且在以下代码中遇到解析错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21420865/
我目前正在开发一个 gameboy 模拟器,为了测试我的模拟器的正确性,我正在使用 GBDK 为我的模拟器编译 c 程序。 我注意到编译器(正如预期的那样)通过旋转优化了与 2 的幂的常量的乘法。然而
我正在尝试将一对结构数组传递给 C 中的函数。 我必须使用 SDCC 编译器,因为我正在使用 GBDK 为 Gameboy 进行编译。 当我传递结构数组时,出现如下所示的错误,但是,如果我完全取出函数
我正在为 GBDK 中的 GameBoy 制作游戏,我正在尝试为游戏添加声音。 GBDK 有一个函数可以播放一组值的声音,唯一的问题是当它播放声音时脚本的其余部分会卡住。有没有办法让它们同时运行? 最
我想使用 GBExtended library在我的游戏中,但我很难理解如何包含该库。 我可以看到 GBExtended 库(至少从 loderrunner 示例源代码)包含目录 includes/、
我正在使用 GBDK C 为原版 Game Boy 创建游戏,但遇到了一个小问题。我游戏中的每个房间都需要有不同的 portal,但每个 portal 都需要引用一个房间。这是代码的缩减版本: typ
#include #include #include "racecars.h" /* RACECARS.C Tile Source File. Info: Form
我是一名优秀的程序员,十分优秀!