C++ Game Error

support for the powerpc toolchain
Post Reply
Ghost6765

C++ Game Error

Post by Ghost6765 » 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:

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 ==========
Here my Source :

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;
}
Here's my Makefile:

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
#---------------------------------------------------------------------------------
Any help is appreciated

:)

zeromus
Posts: 212
Joined: Wed Mar 31, 2010 6:05 pm

Re: C++ Game Error

Post by zeromus » Wed Aug 25, 2010 9:43 pm

enter this code after int GameSpeed = 200;

#define I_NEED_TO_DO_C_TUTORIALS_BEFORE_MESSING_WITH_WII_PROGRAMMING(howbadly) void
#define struct I_NEED_TO_DO_C_TUTORIALS_BEFORE_MESSING_WITH_WII_PROGRAMMING(REALLY BADLY)

WinterMute
Site Admin
Posts: 1845
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: C++ Game Error

Post by WinterMute » Wed Aug 25, 2010 9:45 pm

Start here

http://www.learncpp.com/

You're trying to do too much too soon
Help keep devkitPro toolchains free, Donate today

Personal Blog

ShotgunNinja
Posts: 34
Joined: Tue May 11, 2010 2:29 am

Re: C++ Game Error

Post by ShotgunNinja » Thu Aug 26, 2010 3:27 pm

:o Oh snap.

Basically though, you've obviously never used C++ before, or C for that matter. Pick up a book and learn.

Normally, I'd go through and explain what you did wrong, but the first or second page of a decent beginner's C/C++ tutorial should be able to explain it to you. Sorry, bro.

I started from http://cplusplus.com/doc/tutorial/.

Ghost6765

Re: C++ Game Error

Post by Ghost6765 » Thu Aug 26, 2010 3:51 pm

OH well!!!!!

thanks for the reply anyways except for zeromus that is just rude. I'll go through the tutorials A.S.A.P.

Ghost6765

Re: C++ Game Error

Post by Ghost6765 » Mon Aug 30, 2010 3:57 pm

Can someone recommend some good books.

ShotgunNinja
Posts: 34
Joined: Tue May 11, 2010 2:29 am

Re: C++ Game Error

Post by ShotgunNinja » Tue Aug 31, 2010 4:24 pm

I like the Deitel series. I still carry around the ancient tome "C++ How To Program, 2nd Edition" by Deitel, but I think they're up to 7th Ed. now. Or you could use the book written by the guy who is attributed with the creation of C++, Bjarne Stroustrup. It's called "The C++ Programming Language: Special Edition."

C++ How To Program, 7e:
http://www.amazon.com/How-Program-7th-P ... 85-9679840

The C++ Programming Language: Special Edition:
http://www.amazon.com/C-Programming-Lan ... pd_sim_b_2

Keep in mind that people make very good money (probably less than they should...) from their knowledge and work in programming, for good reason. Programming is like writing, in that anyone can learn to be competent, but fluency, and poetry, require a considerable investment of commitment, focus, and practice.

Also, just from the way you write, it seems like English is not your primary language. If so, then it would probably be better for you if you found a book in your primary language, so you're not struggling with two languages at a time. And if not, well... I wish you the best of luck.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests