C++ Game Error
Posted: Wed Aug 25, 2010 7:45 pm
I have just finished my first rpg game for the wii but when I try to compile I get an error, I use MSVC++ 2010 Express.
Here's My Error:
Here my Source :
Here's my Makefile:
Any help is appreciated
Here's My Error:
Code: Select all
------ Build started: Project: RPG_Game_C++, Configuration: Debug Win32 ------
c:/devkitPro/examples/wii/RPG_Game_C++/source/main.cpp:23: error: expected unqualified-id before ')' token
c:/devkitPro/examples/wii/RPG_Game_C++/source/main.cpp:39: error: expected unqualified-id before ')' token
c:/devkitPro/examples/wii/RPG_Game_C++/source/main.cpp:74: error: expected unqualified-id before ')' token
c:/devkitPro/examples/wii/RPG_Game_C++/source/main.cpp:8: warning: 'xfb' defined but not used
c:/devkitPro/examples/wii/RPG_Game_C++/source/main.cpp:9: warning: 'rmode' defined but not used
main.cpp
make[1]: *** [main.o] Error 1
make: *** [build] Error 2
C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command "make" exited with code 2.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Code: Select all
//MOST OF THE CODE MADE BY batch09master I JUST MADE IT FOR WII!!
#include <iostream>
#include <stdlib.h>
#include <gccore.h>
#include <wiiuse/wpad.h>
using namespace std;
static void *xfb = NULL;
static GXRModeObj *rmode = NULL;
char Map[10][20] = { "##################",
"#@ #",
"# #",
"# #",
"# #",
"# #",
"# #",
"# #",
"##################" };
int GameSpeed = 200;
struct Declarations()
{
// Call WPAD_ScanPads each loop, this reads the latest controller states
WPAD_ScanPads();
// WPAD_ButtonsDown tells us which buttons were pressed in this loop
// this is a "one shot" state which will not fire again until the button has been released
u32 pressed = WPAD_ButtonsDown(0);
// We return to the launcher application via exit
if ( pressed & WPAD_BUTTON_HOME ) exit(0);
// Wait for the next frame
VIDEO_WaitVSync();
}
struct Setup()
{
VIDEO_Init();
// This function initialises the attached controllers
WPAD_Init();
// Obtain the preferred video mode from the system
// This will correspond to the settings in the Wii menu
rmode = VIDEO_GetPreferredMode(NULL);
// Allocate memory for the display in the uncached region
xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
// Initialise the console, required for printf
console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
// Set up the video registers with the chosen mode
VIDEO_Configure(rmode);
// Tell the video hardware where our display memory is
VIDEO_SetNextFramebuffer(xfb);
// Make the display visible
VIDEO_SetBlack(FALSE);
// Flush the video register changes to the hardware
VIDEO_Flush();
// Wait for Video setup to complete
VIDEO_WaitVSync();
if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
}
struct GAME()
{
Setup();
while(1)
{
Declarations();
for ( int y = 0; y < 10; y++ )
{
cout << Map[y] <<endl;
}
for ( int y = 0; y < 10; y++)
{
for ( int x = 0; y < 20; x++ )
{
switch(Map[y][x])
{
case '@':
{
if ( pressed & WPAD_BUTTON_UP )
{
int y2 = (y - 1);
switch(Map[y2][x])
{
case ' ':
{
Map[y][x]= ' ';
y -= 1;
Map[y2][x] = '@';
}
}
}
if ( pressed & WPAD_BUTTON_DOWN )
{
int y2 = (y + 1);
switch(Map[y2][x])
{
case ' ':
{
Map[y][x]= ' ';
y += 1;
Map[y2][x] = '@';
}
}
}
if ( pressed & WPAD_BUTTON_LEFT )
{
int x2 = (x - 1);
switch(Map[y][x2])
{
case ' ':
{
Map[y][x]= ' ';
x -= 1;
Map[y][x2] = '@';
}
}
}
if ( pressed & WPAD_BUTTON_RIGHT )
{
int x2 = (x + 1);
switch(Map[y][x2])
{
case ' ':
{
Map[y][x]= ' ';
x += 1;
Map[y][x2] = '@';
}
}
}
}break;
}
}
}
Sleep(GameSpeed);
}
}
int main(int argc, char **argv)
{
Game();
return 0;
}
Code: Select all
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
endif
include $(DEVKITPPC)/wii_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source
DATA := data
INCLUDES :=
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE)
CXXFLAGS = $(CFLAGS)
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lwiiuse -lbte -logc -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS :=
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
#---------------------------------------------------------------------------------
# automatically build a list of object files for our project
#---------------------------------------------------------------------------------
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
export LD := $(CC)
else
export LD := $(CXX)
endif
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
$(sFILES:.s=.o) $(SFILES:.S=.o)
#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE := $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD) \
-I$(LIBOGC_INC)
#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
-L$(LIBOGC_LIB)
export OUTPUT := $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
#---------------------------------------------------------------------------------
run:
wiiload $(TARGET).dol
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).dol: $(OUTPUT).elf
$(OUTPUT).elf: $(OFILES)
#---------------------------------------------------------------------------------
# This rule links in binary data with the .jpg extension
#---------------------------------------------------------------------------------
%.jpg.o : %.jpg
#---------------------------------------------------------------------------------
@echo $(notdir $<)
$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------