forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

2D draw methods/ Java -> C++
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Nine_Masquerade_



Joined: 18 Jun 2009
Posts: 26

PostPosted: Mon Jul 20, 2009 10:11 am    Post subject: 2D draw methods/ Java -> C++ Reply with quote

Hi, i am completely new to C++ coming entirely from a Java background and was wondering which C++/PSP lib functions would do the following:

-Created a buffered image with set width and height.

-Draw an image to an x and y coordinate on that buffered image.

-Blit the buffered image to the PSP screen.

So far i have come this far with my code using the files from this page (files are found in the second paragraph):

http://www.psp-programming.com/tutorials/c/lesson04-2.htm

Code:
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspgu.h>
#include <png.h>
#include <stdio.h>
#include "graphics.h"

PSP_MODULE_INFO("Image Display Program", 0, 1, 1);

#define printf pspDebugScreenPrintf

/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
          sceKernelExitGame();
          return 0;
}

/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
          int cbid;

          cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
          sceKernelRegisterExitCallback(cbid);

          sceKernelSleepThreadCB();

          return 0;
}

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
          int thid = 0;

          thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
          if(thid >= 0) {
                    sceKernelStartThread(thid, 0, 0);
          }

          return thid;
}

int main() {
   char buffer[200];
   Image* ourImage;
   pspDebugScreenInit();
   SetupCallbacks();
   initGraphics();
   sprintf(buffer, "cylus.png");
   ourImage = loadImage(buffer);
   int x = 240;
   int y = 136;
   sceDisplayWaitVblankStart();
   SceCtrlData pad;
   while(1)
   {
      sceCtrlReadBufferPositive(&pad, 1);
      if(pad.Buttons & PSP_CTRL_LEFT)
         x--;
      if(pad.Buttons & PSP_CTRL_RIGHT)
            x++;
      if(pad.Buttons & PSP_CTRL_UP)
            y--;
      if(pad.Buttons & PSP_CTRL_DOWN)
            y++;
      if(pad.Buttons & PSP_CTRL_TRIANGLE)
            break;
      blitAlphaImageToScreen(0 ,0 ,16 , 20, ourImage, x, y);
      flipScreen();
   }
   sceKernelSleepThread();
   return 0;
}


The problem is, the sprite draws to the screen and successfully moves, but the screen does not refresh to being blank before the next coordinate is drawn. Redrawing to a buffered image 480x272 and then blitting that to the screen would avoid this and is the method i usually use in my Java programs.

Any help is greatly appreciated!


Last edited by Nine_Masquerade_ on Tue Jul 21, 2009 12:25 pm; edited 1 time in total
Back to top
View user's profile Send private message
psPea



Joined: 01 Sep 2007
Posts: 64

PostPosted: Mon Jul 20, 2009 10:43 am    Post subject: Reply with quote

You have to clear the draw buffer.
use
clearScreen(0);
before drawing

>Redrawing to a buffered image 480x272 and then blitting that to the screen would avoid this and is the method i usually use in my Java programs.

That would be to avoid flickering and the pspgu uses double buffering, you'd still have to clear the screen.
_________________
Click ME!
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Nine_Masquerade_



Joined: 18 Jun 2009
Posts: 26

PostPosted: Tue Jul 21, 2009 1:31 am    Post subject: Reply with quote

Thanks! It works perfectly.

A couple other questions:

-How do you define a custom color (through RBG values) and then set the background as that color?

-is it possible to have a constructor take main as a parameter so that i can do main.blitImageToScreen(blah, blah, blah); as the draw method within a object?

-Also i have both .c files and .cpp files in my project folder. can C and C++ files be used together??
Back to top
View user's profile Send private message
psPea



Joined: 01 Sep 2007
Posts: 64

PostPosted: Tue Jul 21, 2009 5:40 am    Post subject: Reply with quote

>How do you define a custom color (through RBG values) and then set the background as that color?

open up graphics.c and go to the clearScreen and add
sceGuClearColor(color);
before
sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);

then
when calling clearScreen, pass the colour you want to use as the background colour.
use GU_RGBA(r,g,b,a) to make your colour from red,green, blue ,and alpha values.
if you get an undefined reference to GU_RGBA add
#include <pspgu.h> to you code.

>Also i have both .c files and .cpp files in my project folder. can C and C++ files be used together??

Sure

>is it possible to have a constructor take main as a parameter so that i can do main.blitImageToScreen(blah, blah, blah); as the draw method within a object?

what?
_________________
Click ME!
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Nine_Masquerade_



Joined: 18 Jun 2009
Posts: 26

PostPosted: Tue Jul 21, 2009 7:39 am    Post subject: Reply with quote

Thanks for your very prompt and comprehensible tips psPea; it works great!

What I meant by this:

>is it possible to have a constructor take main as a parameter so that i can do main.blitImageToScreen(blah, blah, blah); as the draw method within a object?

Is this:

Suppose I had a class called "You". In the java version of my game, the constructor takes in an "Applet".

Code:
public You(Applet myApplet)
   {
   code
   }


So in the Applet itself, when you declare the You object, you see:
Code:

y = new You(this);


In the java version "You" gets the character/blood images through myApplet like so:

Code:
      for(int i = 0; i < 8; i++)
      {
      img = myApplet.getImage(myApplet.getCodeBase(), "blood"+i+".png");
      blood.add(img);
      }


The Applet that is being passed into "You" in the java version is basically main.c for the C/C++ version (both contain the main method for the program).

So my question is (in regards to the C/C++ version)... can i pass main.c into "You"'s constructor as a parameter like so:

Code:
You::You(main m)
{
code
}


so as to then call

Code:
sprintf(buffer, "cylus.png");
   ourImage = loadImage(buffer);


and

Code:
blitAlphaImageToScreen(0 ,0 ,16 , 20, ourImage, x, y);


so that "You" can instantiate and govern its own .pngs and have its own "draw" method yet do it by using main.c?

Basically what I am asking is can main.c be passed as a parameter and then used in methods inside of other objects?
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Tue Jul 21, 2009 8:23 am    Post subject: Reply with quote

Nine_Masquerade_ wrote:
Basically what I am asking is can main.c be passed as a parameter and then used in methods inside of other objects?


No. You need to go review your C++ a bit. Remember that C++ is the same on the PSP as on any other platform. If you can/can't do it on a PC, you can/can't do it on the PSP.
Back to top
View user's profile Send private message AIM Address
psPea



Joined: 01 Sep 2007
Posts: 64

PostPosted: Tue Jul 21, 2009 8:30 am    Post subject: Reply with quote

I've never used applets in Java so I have no clue what you're talking about.

>So my question is (in regards to the C/C++ version)... can i pass main.c into "You"'s constructor as a parameter like so:

I'm not sure what you mean, but I'm certain the answer is no.

If you want "You" to instantiate and govern its own .pngs and have its own "draw" method, then do it, you don't need main.


Code:
class You{
.
.
.
public:
         You(){
          for(int i = 0; i < 8; i++) {
            char file[100];     
            sprintf(file, "blood%d.png", i);               
            Image img = loadImage(file);
            blood.insert(img);
          }
         }
         draw(int srcx ,int srcy ,int width, int height, Image *ourImage, int x, int y){
            blitAlphaImageToScreen(srcx ,srcy ,width, height, ourImage, x, y);
         }
.
.
.
};

_________________
Click ME!
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Nine_Masquerade_



Joined: 18 Jun 2009
Posts: 26

PostPosted: Tue Jul 21, 2009 8:34 am    Post subject: Reply with quote

lol i agree J.F.. I do need to review my C++ a bit. Ive realized what i was trying to do didnt make too much sense, so what im trying now is this (just an example from within "You.h"):
Code:

      for( int i = 0; i < 6; i++ )
      {
         sprintf(buffer, "cylus"+i+".png");
         img = loadImage(buffer);
         playerPics[i] = im;
      }


Im currently still making changes, but ill let you know if what im trying works. And I apologize if it is at times annoying that i am not too adept with C++. Ive found that the fastest way to learn and retain a language is through trial and error and i appreciate all of the help ive been given more than you guys can imagine :)
Back to top
View user's profile Send private message
Nine_Masquerade_



Joined: 18 Jun 2009
Posts: 26

PostPosted: Tue Jul 21, 2009 8:37 am    Post subject: Reply with quote

I was just gonna try that psPea.
Working on it now...
Back to top
View user's profile Send private message
Nine_Masquerade_



Joined: 18 Jun 2009
Posts: 26

PostPosted: Tue Jul 21, 2009 10:44 am    Post subject: Reply with quote

Almost done.
Quick question though.

Can i make ArrayLists in C++ like i can in Java?

Im almost positive i cant, but its strange because dont have any syntax errors for lines like this:

Code:
   ArrayList<Image> flamethrower = new ArrayList<Image>();


yet for some reason when i try making an ArrayList of ArrayLists like this:

Code:
ArrayList<ArrayList<Image>> weapon = new ArrayList<ArrayList<Image>>();


i get a syntax error.
Please let me know if im wrong about ArrayLists in C++ and if im not, it would help a bunch if you know why im getting this error.


Last edited by Nine_Masquerade_ on Tue Jul 21, 2009 11:15 am; edited 1 time in total
Back to top
View user's profile Send private message
psPea



Joined: 01 Sep 2007
Posts: 64

PostPosted: Tue Jul 21, 2009 11:14 am    Post subject: Reply with quote

put a space between the two >
change >>
to > >

also I didn't know there was ArrayList in C++
_________________
Click ME!
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Nine_Masquerade_



Joined: 18 Jun 2009
Posts: 26

PostPosted: Tue Jul 21, 2009 11:20 am    Post subject: Reply with quote

lol thats why i changed my post to "im almost positive i cant".
The error went away when i did what you said, but i did a little test, where i misspell "ArrayList", save, and no errors show up...

Im not sure why its not detecting a syntax error when i misspell ArrayList.

Ill see what happens when i finish transcoding it to C++ and try and compile.

Fingers are crossed.
Back to top
View user's profile Send private message
Nine_Masquerade_



Joined: 18 Jun 2009
Posts: 26

PostPosted: Tue Jul 21, 2009 11:37 am    Post subject: Reply with quote

Hmm found something worth looking at.
I ran my java source through a java -> C++ translator and it changed the ArrayLists like this:
Code:

ArrayList<Image> flamethrower = new ArrayList<Image>();


is now

Code:
std::vector<Image*> flamethrower = std::vector<Image*>();


I am not too sure what this means. Could someone enlighten me?
Back to top
View user's profile Send private message
psPea



Joined: 01 Sep 2007
Posts: 64

PostPosted: Tue Jul 21, 2009 11:53 am    Post subject: Reply with quote

http://www.cplusplus.com/reference/stl/vector/
and
http://www.cplusplus.com/reference/

one thing to note in Java object variables store reference to objects, in C++ that's not the case, notice how they changed Image to Image*.
If you add an object to any of those containers they add a copy of it and not the object itself, so making the vector type a pointer to the object may be more desireable.
_________________
Click ME!
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Nine_Masquerade_



Joined: 18 Jun 2009
Posts: 26

PostPosted: Tue Jul 21, 2009 12:16 pm    Post subject: Reply with quote

Thank you. This helps tremendously.

I am using eclipse Galileo and i know for a fact there are many syntax errors that are not being shown. Having realized this, this process may take a couple more days :( but im up to the task. Is there something I can change in my eclipse preferences so these errors will show?

Also, in java as you probably know there is a built in Rectangle object, which i use extensively for collision tests in my code. Do you know if C++ has a Rectangle object that contains functions which tell if something is inside the Rectangle, on its border, etc.?
Back to top
View user's profile Send private message
psPea



Joined: 01 Sep 2007
Posts: 64

PostPosted: Tue Jul 21, 2009 12:33 pm    Post subject: Reply with quote

Do you know if C++ has a Rectangle object that contains functions which tell if something is inside the Rectangle, on its border, etc.?

why not try running the rectangle class through the converter?


>I am using eclipse Galileo and i know for a fact there are many syntax errors that are not being shown. Having realized this, this process may take a couple more days :( but im up to the task. Is there something I can change in my eclipse preferences so these errors will show?

I don't know about eclipse, but why not try compiling it?
_________________
Click ME!
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Nine_Masquerade_



Joined: 18 Jun 2009
Posts: 26

PostPosted: Tue Jul 21, 2009 1:30 pm    Post subject: Reply with quote

All i found for the java Rectangle class source was this:

http://kickjava.com/src/java/awt/Rectangle.java.htm

I also found this

http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGdk_1_1Rectangle.html

Which i think might prove to be more practical. But since im developing under MinPSPw, im not sure how to install these packages. Any ideas?
Back to top
View user's profile Send private message
Nine_Masquerade_



Joined: 18 Jun 2009
Posts: 26

PostPosted: Wed Jul 22, 2009 11:43 am    Post subject: Reply with quote

Im just going to make my own rectangle class using this algorithm:


In the case of axis-aligned ones, there are at most four checks you need to perform:
1. Check if box A is completely to the left of box B (a.left <= b.right). If so, then quit the process: they don't intersect.
2. Otherwise, check if it's completely to the right (a.right >= b.left). If so, quit the process.
3. If not, check if it's completely above box B (a.bottom >= b.top). If so, quit.
4. If not, check if it's completely beneath box B (a.top <= b.bottom). If so, quit.
If not, then the boxes intersect.
Back to top
View user's profile Send private message
Nine_Masquerade_



Joined: 18 Jun 2009
Posts: 26

PostPosted: Wed Jul 22, 2009 1:37 pm    Post subject: Reply with quote

As I've said before, im not too adept in C++, and therefore i cannot figure out what i am doing wrong here :(. When i try to compile this test code i get these errors:


**** Build of configuration Default for project ITAWAS ****

make all
psp-gcc -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=150 -c -o main.o main.c
In file included from main.c:10:
./Rectangle.h:9:20: error: iostream: No such file or directory
In file included from main.c:10:
./Rectangle.h:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Rectangle'
main.c: In function 'main':
main.c:56: error: 'Rectangle' undeclared (first use in this function)
main.c:56: error: (Each undeclared identifier is reported only once
main.c:56: error: for each function it appears in.)
main.c:56: error: expected ';' before 'r'
make: *** [main.o] Error 1

Here is Rectangle.h:

Code:
#ifndef RECTANGLE_H_
#define RECTANGLE_H_



class Rectangle
{
public:
   int X;
   int Y;
   int WIDTH;
   int HEIGHT;
   int bottom;
   int right;

   Rectangle(int x, int y, int width, int height)
   {
      X = x;
      Y = y;
      WIDTH = width;
      HEIGHT = height;
      right = X + WIDTH;
      bottom = Y + HEIGHT;
   }

   virtual void setRect(int x, int y, int width, int height)
   {
      X = x;
      Y = y;
      WIDTH = width;
      HEIGHT = height;
      right = X + WIDTH;
      bottom = Y + HEIGHT;
   }

   virtual bool intersects(Rectangle r)
   {
      if(X >= r.getRight())
         return false;
      else if(right <= r.getX())
         return false;
      else if(Y >= r.getBottom())
         return false;
      else if(bottom <= r.getY())
         return false;
      else return true;
   }

   virtual int getX()
   {
      return X;
   }

   virtual int getY()
   {
      return Y;
   }

   virtual int getBottom()
   {
      return bottom;
   }

   virtual int getRight()
   {
      return right;
   }
};
#endif /* RECTANGLE_H_ */



And here is main.c:

Code:
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspgu.h>
#include <png.h>
#include <stdio.h>
#include "graphics.h"
#include <stdbool.h>





PSP_MODULE_INFO("Image Display Program", 0, 1, 1);

#define printf pspDebugScreenPrintf

/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
          sceKernelExitGame();
          return 0;
}

/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
          int cbid;

          cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
          sceKernelRegisterExitCallback(cbid);

          sceKernelSleepThreadCB();

          return 0;
}

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
          int thid = 0;

          thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
          if(thid >= 0) {
                    sceKernelStartThread(thid, 0, 0);
          }

          return thid;
}

int main() {
   //Direction Booleans
   bool LEFT;
   bool RIGHT;
   bool RTRIGGER;
   bool CROSS;
   bool START;
   Rectangle r(0, 0, 0, 0);


   pspDebugScreenInit();
   SetupCallbacks();
   initGraphics();
   sceDisplayWaitVblankStart();
   SceCtrlData pad;
   while(1)
   {
      sceCtrlReadBufferPositive(&pad, 1);
      if(pad.Buttons & PSP_CTRL_LEFT)
            LEFT = true;
      else LEFT = false;
      if(pad.Buttons & PSP_CTRL_RIGHT)
            RIGHT = true;
      else RIGHT = false;
      if(pad.Buttons & PSP_CTRL_CROSS)
            CROSS = true;
      else CROSS = false;
      if(pad.Buttons & PSP_CTRL_START)
            START = true;
      else START = false;
      if(pad.Buttons & PSP_CTRL_RTRIGGER)
            RTRIGGER = true;
      else RTRIGGER = false;

      clearScreen(GU_RGBA(181, 186, 254, 1));
      flipScreen();


   }
   sceKernelSleepThread();
   return 0;
}
Back to top
View user's profile Send private message
psPea



Joined: 01 Sep 2007
Posts: 64

PostPosted: Wed Jul 22, 2009 1:54 pm    Post subject: Reply with quote

change main.c to main.cpp
and add -lstdc++ to LIBS in your makefile
_________________
Click ME!
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Nine_Masquerade_



Joined: 18 Jun 2009
Posts: 26

PostPosted: Wed Jul 22, 2009 2:26 pm    Post subject: Reply with quote

Thanks for your continued help psPea.

I renamed main.c to main.cpp and added -lstdc++ to LIBS.

Now i get this error:


**** Build of configuration Default for project ITAWAS ****

make all
psp-g++ -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -fno-exceptions -fno-rtti -D_PSP_FW_VERSION=150 -c -o main.o main.cpp
main.cpp: In function 'int main()':
main.cpp:57: error: 'Rectangle' was not declared in this scope
main.cpp:57: error: expected `;' before 'r'
make: *** [main.o] Error 1

EDIT 1:

For the heck of it, after making the changes i commented out the line where i construct the Rectangle and then tried compiling. Then i get these errors:

**** Build of configuration Default for project ITAWAS ****

make all
psp-gcc -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=150 -L. -LC:/pspsdk/psp/sdk/lib main.o graphics.o framebuffer.o -lpspgu -lpng -lz -lm -lstdc++ -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o hello.elf
main.o: In function `main':
main.cpp:(.text+0x74): undefined reference to `initGraphics()'
main.cpp:(.text+0x98): undefined reference to `clearScreen(unsigned int)'
main.cpp:(.text+0xa0): undefined reference to `flipScreen()'
collect2: ld returned 1 exit status
make: *** [hello.elf] Error 1
Back to top
View user's profile Send private message
psPea



Joined: 01 Sep 2007
Posts: 64

PostPosted: Wed Jul 22, 2009 2:54 pm    Post subject: Reply with quote

I'm now reading your code and I see that Rectangle.h isn't included in main

also I believe graphics.h isn't wrapped in an extern "C"
so
change
#include "graphics.h"
to
extern "C"
{
#include "graphics.h"
}
_________________
Click ME!
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Nine_Masquerade_



Joined: 18 Jun 2009
Posts: 26

PostPosted: Fri Jul 24, 2009 3:58 am    Post subject: Reply with quote

Yes that did solve that error, but now sadly i am getting more...

I did some cleanup and reduced the errors as much as i could, but now i've got some i can't figure out. In all i have 9 classes and each are experiencing similar errors when i try to compile. So solving them in one class will help me solve the rest. Ill show You.h's errors:

./You.h:46: error: ISO C++ forbids declaration of 'Rectangle' with no type
./You.h:46: error: expected ';' before '*' token
./You.h:47: error: ISO C++ forbids declaration of 'Rectangle' with no type
./You.h:47: error: expected ';' before '*' token
./You.h:48: error: ISO C++ forbids declaration of 'Rectangle' with no type
./You.h:48: error: expected ';' before '*' token
./You.h:49: error: ISO C++ forbids declaration of 'Rectangle' with no type
./You.h:49: error: expected ';' before '*' token
./You.h:50: error: ISO C++ forbids declaration of 'Rectangle' with no type
./You.h:50: error: expected ';' before '*' token
./You.h:113: error: 'Terrain' was not declared in this scope
./You.h:113: error: template argument 1 is invalid
./You.h:113: error: template argument 2 is invalid
./You.h:126: error: ISO C++ forbids declaration of 'Rectangle' with no type
./You.h:126: error: 'Rectangle' declared as a 'virtual' field
./You.h:126: error: expected ';' before '*' token
./You.h:137: error: 'Terrain' was not declared in this scope
./You.h:137: error: template argument 1 is invalid
./You.h:137: error: template argument 2 is invalid
./You.h:137: error: 'Projectile' was not declared in this scope
./You.h:137: error: template argument 1 is invalid
./You.h:137: error: template argument 2 is invalid
./You.h:137: error: 'object' was not declared in this scope
./You.h:137: error: template argument 1 is invalid
./You.h:137: error: template argument 2 is invalid

Here is You.h:

Code:
#pragma once
#include <string>
#include <vector>
#include <cmath>
#include <Enemy.h>
#include <LevelPack.h>
#include <Object.h>
#include <Projectile.h>
#include <Rectangle.h>
#include <Shop.h>
#include <Terrain.h>
#include <TextOverlay.h>


class You
{

public:
//INSTANT C++ TODO TASK: Native C++ only allows initialization of static const integral fields in their declarations:
   int WIDTH;
//INSTANT C++ TODO TASK: Native C++ only allows initialization of static const integral fields in their declarations:
   int HEIGHT;
   int pX;
   int pY;
   int deltaD;
//INSTANT C++ TODO TASK: Native C++ only allows initialization of static const integral fields in their declarations:
   int xPos;
//INSTANT C++ TODO TASK: Native C++ only allows initialization of static const integral fields in their declarations:
   int yPos;
   int animateY;
   Image *im;
   //Blood
   Image *img;
   int xBlood;
   int yBlood;
   int bloodCount;
   int bL;
//INSTANT C++ TODO TASK: Native C++ only allows initialization of static const integral fields in their declarations:
   int healthMax;
//INSTANT C++ TODO TASK: Native C++ only allows initialization of static const integral fields in their declarations:
   int health;
   int money;
   bool dead;

//INSTANT C++ TODO TASK: Native C++ only allows initialization of static const integral fields in their declarations:
   Rectangle *r;
   Rectangle *r0;
   Rectangle *r1;
   Rectangle *rL;
   Rectangle *rR;
//ORIGINAL LINE: Image[] playerPics;
//INSTANT C++ WARNING: Since the array size is not known in this declaration, Instant C++ has converted this array to a pointer.  You will need to call 'delete[]' where appropriate:
   Image *playerPics;
//INSTANT C++ TODO TASK: Native C++ only allows initialization of static const integral fields in their declarations:
   std::vector<Image*> blood;
   //Projectile variables
//INSTANT C++ TODO TASK: Native C++ only allows initialization of static const integral fields in their declarations:
   std::string P_TYPE;
   int M_TYPE;
   //Physics related variables
   bool grounded;
   //initial jump dir: 0 = L, 1 = R, -5 = not jumping
   int iJump;
   bool maintain;
   int dir;
   int t;
   int v;
//INSTANT C++ TODO TASK: Native C++ only allows initialization of static const integral fields in their declarations:
   int a;
//INSTANT C++ TODO TASK: Native C++ only allows initialization of static const integral fields in their declarations:
   int MAX;



   //Creates the player
   You();

   //Set Your Current Position
   virtual void setPos();

   //Sets old
   virtual void setPre();

   //Set Pos for level
   virtual void setXY(int x, int y);

   virtual void setMoney(int i);
   //Draws You
   virtual void draw();



   //Tests for L and sets xPos and animation type
   virtual int walkL(bool buttonEventL);





   //Tests for R and sets xPos and animation type
   virtual int walkR(bool buttonEventR);




   //Tests for S and sets yPos
   virtual void jump(bool buttonEventS);




   //Tests if you are in free fall and sets yPos
   virtual void gravity(std::vector<Terrain*> &pack);

   //Return methods
   virtual int getX();

   virtual int getY();

   virtual std::string getPType();

   virtual int getMType();

   virtual int getAnim();

   virtual Rectangle *getRect();

   virtual int getVel();

   virtual int getHealth();

   virtual bool getStatus();

   virtual int getMoney();


   virtual void colTestTer(std::vector<Terrain*> &pack, std::vector<Projectile*> &proj, std::vector<object*> &pickups);

   //Determines death- prevents all movement and loops through blood sequence.
   virtual void healthTest();


};


I am extremely grateful for any help people can offer.
Back to top
View user's profile Send private message
psPea



Joined: 01 Sep 2007
Posts: 64

PostPosted: Fri Jul 24, 2009 4:24 am    Post subject: Reply with quote

I'm thinking your header files aren't found
are they in the same folder as you.h
if so change
#include <header.h>
to
#include "header.h"
_________________
Click ME!
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Nine_Masquerade_



Joined: 18 Jun 2009
Posts: 26

PostPosted: Fri Jul 24, 2009 5:43 am    Post subject: Reply with quote

Thanks! Yea, the header files are all in the same directory. That helped me narrow down the error log to this:

You.h:46: error: ISO C++ forbids declaration of 'Rectangle' with no type
You.h:46: error: expected ';' before '*' token
You.h:47: error: ISO C++ forbids declaration of 'Rectangle' with no type
You.h:47: error: expected ';' before '*' token
You.h:48: error: ISO C++ forbids declaration of 'Rectangle' with no type
You.h:48: error: expected ';' before '*' token
You.h:49: error: ISO C++ forbids declaration of 'Rectangle' with no type
You.h:49: error: expected ';' before '*' token
You.h:50: error: ISO C++ forbids declaration of 'Rectangle' with no type
You.h:50: error: expected ';' before '*' token
You.h:126: error: ISO C++ forbids declaration of 'Rectangle' with no type
You.h:126: error: 'Rectangle' declared as a 'virtual' field
You.h:126: error: expected ';' before '*' token
You.h:137: error: 'Projectile' was not declared in this scope
You.h:137: error: template argument 1 is invalid
You.h:137: error: template argument 2 is invalid
You.h:137: error: 'object' was not declared in this scope
You.h:137: error: template argument 1 is invalid
You.h:137: error: template argument 2 is invalid

There's three basic areas where errors are arising from. I Put asterisks to the right of these lines:
Code:

#pragma once
#include <string>
#include <vector>
#include <cmath>
#include "Enemy.h"
#include "LevelPack.h"
#include "Object.h"
#include "Projectile.h"
#include "Rectangle.h"
#include "Shop.h"
#include "TextOverlay.h"
#include "Terrain.h"


class You
{

public:
//INSTANT C++ TODO TASK: Native C++ only allows initialization of static const integral fields in their declarations:
   int WIDTH;
//INSTANT C++ TODO TASK: Native C++ only allows initialization of static const integral fields in their declarations:
   int HEIGHT;
   int pX;
   int pY;
   int deltaD;
//INSTANT C++ TODO TASK: Native C++ only allows initialization of static const integral fields in their declarations:
   int xPos;
//INSTANT C++ TODO TASK: Native C++ only allows initialization of static const integral fields in their declarations:
   int yPos;
   int animateY;
   Image *im;
   //Blood
   Image *img;
   int xBlood;
   int yBlood;
   int bloodCount;
   int bL;
//INSTANT C++ TODO TASK: Native C++ only allows initialization of static const integral fields in their declarations:
   int healthMax;
//INSTANT C++ TODO TASK: Native C++ only allows initialization of static const integral fields in their declarations:
   int health;
   int money;
   bool dead;

//INSTANT C++ TODO TASK: Native C++ only allows initialization of static const integral fields in their declarations:
   Rectangle *r;        ****ERROR
   Rectangle *r0;      ****ERROR
   Rectangle *r1;      ****ERROR
   Rectangle *rL;      ****ERROR
   Rectangle *rR;      ****ERROR
//ORIGINAL LINE: Image[] playerPics;
//INSTANT C++ WARNING: Since the array size is not known in this declaration, Instant C++ has converted this array to a pointer.  You will need to call 'delete[]' where appropriate:
   Image *playerPics;
//INSTANT C++ TODO TASK: Native C++ only allows initialization of static const integral fields in their declarations:
   std::vector<Image*> blood;
   //Projectile variables
//INSTANT C++ TODO TASK: Native C++ only allows initialization of static const integral fields in their declarations:
   std::string P_TYPE;
   int M_TYPE;
   //Physics related variables
   bool grounded;
   //initial jump dir: 0 = L, 1 = R, -5 = not jumping
   int iJump;
   bool maintain;
   int dir;
   int t;
   int v;
//INSTANT C++ TODO TASK: Native C++ only allows initialization of static const integral fields in their declarations:
   int a;
//INSTANT C++ TODO TASK: Native C++ only allows initialization of static const integral fields in their declarations:
   int MAX;



   //Creates the player
   You();

   //Set Your Current Position
   virtual void setPos();

   //Sets old
   virtual void setPre();

   //Set Pos for level
   virtual void setXY(int x, int y);

   virtual void setMoney(int i);
   //Draws You
   virtual void draw();



   //Tests for L and sets xPos and animation type
   virtual int walkL(bool buttonEventL);





   //Tests for R and sets xPos and animation type
   virtual int walkR(bool buttonEventR);




   //Tests for S and sets yPos
   virtual void jump(bool buttonEventS);




   //Tests if you are in free fall and sets yPos
   virtual void gravity(std::vector<Terrain*> &pack);

   //Return methods
   virtual int getX();

   virtual int getY();

   virtual std::string getPType();

   virtual int getMType();

   virtual int getAnim();

   virtual Rectangle *getRect();      ****ERROR

   virtual int getVel();

   virtual int getHealth();

   virtual bool getStatus();

   virtual int getMoney();


   virtual void colTestTer(std::vector<Terrain*> &pack, std::vector<Projectile*> &proj, std::vector<object*> &pickups);      ****ERROR

   //Determines death- prevents all movement and loops through blood sequence.
   virtual void healthTest();


};


Let me know if you need to see more code if itll help.
Back to top
View user's profile Send private message
psPea



Joined: 01 Sep 2007
Posts: 64

PostPosted: Fri Jul 24, 2009 6:07 am    Post subject: Reply with quote

>Let me know if you need to see more code if itll help.

the whole compile log would be useful too
_________________
Click ME!
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Nine_Masquerade_



Joined: 18 Jun 2009
Posts: 26

PostPosted: Fri Jul 24, 2009 6:23 am    Post subject: Reply with quote

Sure. Here is the whole log:


**** Build of configuration Default for project ITAWAS ****

make all
psp-g++ -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -fno-exceptions -fno-rtti -D_PSP_FW_VERSION=150 -c -o main.o main.cpp
In file included from You.h:12,
from TextOverlay.h:9,
from Shop.h:9,
from Rectangle.h:13,
from Projectile.h:9,
from Object.h:5,
from LevelPack.h:5,
from Enemy.h:5,
from main.cpp:12:
Terrain.h:17: error: ISO C++ forbids declaration of 'Rectangle' with no type
Terrain.h:17: error: expected ';' before '*' token
Terrain.h:29: error: ISO C++ forbids declaration of 'Rectangle' with no type
Terrain.h:29: error: 'Rectangle' declared as a 'virtual' field
Terrain.h:29: error: expected ';' before '*' token
In file included from TextOverlay.h:9,
from Shop.h:9,
from Rectangle.h:13,
from Projectile.h:9,
from Object.h:5,
from LevelPack.h:5,
from Enemy.h:5,
from main.cpp:12:
You.h:46: error: ISO C++ forbids declaration of 'Rectangle' with no type
You.h:46: error: expected ';' before '*' token
You.h:47: error: ISO C++ forbids declaration of 'Rectangle' with no type
You.h:47: error: expected ';' before '*' token
You.h:48: error: ISO C++ forbids declaration of 'Rectangle' with no type
You.h:48: error: expected ';' before '*' token
You.h:49: error: ISO C++ forbids declaration of 'Rectangle' with no type
You.h:49: error: expected ';' before '*' token
You.h:50: error: ISO C++ forbids declaration of 'Rectangle' with no type
You.h:50: error: expected ';' before '*' token
You.h:126: error: ISO C++ forbids declaration of 'Rectangle' with no type
You.h:126: error: 'Rectangle' declared as a 'virtual' field
You.h:126: error: expected ';' before '*' token
You.h:137: error: 'Projectile' was not declared in this scope
You.h:137: error: template argument 1 is invalid
You.h:137: error: template argument 2 is invalid
You.h:137: error: 'object' was not declared in this scope
You.h:137: error: template argument 1 is invalid
You.h:137: error: template argument 2 is invalid
In file included from Object.h:5,
from LevelPack.h:5,
from Enemy.h:5,
from main.cpp:12:
Projectile.h:44: error: 'Enemy' has not been declared
In file included from Enemy.h:5,
from main.cpp:12:
LevelPack.h:23: error: 'Enemy' was not declared in this scope
LevelPack.h:23: error: template argument 1 is invalid
LevelPack.h:23: error: template argument 2 is invalid
LevelPack.h:57: error: 'Enemy' has not been declared
LevelPack.h:66: error: 'Enemy' was not declared in this scope
LevelPack.h:66: error: template argument 1 is invalid
LevelPack.h:66: error: template argument 2 is invalid
LevelPack.h:74: error: 'Enemy' was not declared in this scope
LevelPack.h:74: error: template argument 1 is invalid
LevelPack.h:74: error: template argument 2 is invalid
make: *** [main.o] Error 1
Back to top
View user's profile Send private message
psPea



Joined: 01 Sep 2007
Posts: 64

PostPosted: Fri Jul 24, 2009 10:40 am    Post subject: Reply with quote

You're trying to use classes before they are defined(I think)

If you upload all the files I could take a look at it.
_________________
Click ME!
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Nine_Masquerade_



Joined: 18 Jun 2009
Posts: 26

PostPosted: Fri Jul 24, 2009 11:52 am    Post subject: Reply with quote

Thanks pspPea
I could email you the project... just pm me your email address.

EDIT
Is it cool if i send it to this address: somethingsweet2bad@yahoo.com ?
Back to top
View user's profile Send private message
psPea



Joined: 01 Sep 2007
Posts: 64

PostPosted: Sat Jul 25, 2009 8:13 am    Post subject: Reply with quote

>Is it cool if i send it to this address: somethingsweet2bad@yahoo.com ?

sure, I don't know who would get it though AS ITS NOT MINE

I sent you a pm with my email address
just change -at- to @ and -dot- to .

or you could upload it to mediafire or some other free file hosting site and post the link here.
_________________
Click ME!
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group