Ok, youresame told me to tell you thisZitat:
Zitat von Lukeson
Not sure what it means, do you?....Zitat:
>
Printable View
Ok, youresame told me to tell you thisZitat:
Zitat von Lukeson
Not sure what it means, do you?....Zitat:
>
It's faster to blit the arrows separately.
ok.i have a bullet class, and i want to use an array with bullets is it, but its giving me errors. my code:
Code:Image * player;
Image * bullet;
Image * cursor;
int crossPressed = 1;
int currentBullet = 1;
class bullet
{
public:
int x;
int y;
int fire;
float angle;
int speed;
};
bullet hBullet[];
int main(void) {
pspDebugScreenInit();
SetupCallbacks();
initGraphics();
SceCtrlData pad;
player = loadImage("player.png");
bullet = loadImage("bullet.png");
cursor = loadImage("cursor.png");
while (1) {
sceCtrlReadBufferPositive(&pad, 1);
sceDisplayWaitVblankStart();
flipScreen();
}
return 0;
}
but it gives me this error:
and here is line 66:Code:main.cpp:66: error: 'bullet' does not name a type
make: *** [main.o] Error 1
Code:bullet hBullet[];
what wrong?
Im sure you can convert that to a structure...
That will make it work. But, thats not really what you asked, rather an alternative if your in a hurry. Hope someone answers your question! (oh and maybe a google search on classes will help?)Code:typedef struct bullet
{
int x;
int y;
int fire;
float angle;
int speed;
} bullet;
You have to declare how many bullets you want in the array. You can't just use xxxxxxx[]. It has to be xxxxxxxxxx[4].
When you create an array, you have to declare the size of it on construction.
Zitat:
Zitat von head_54us
nope, still the same error. i definied it like this now:
Code:bullet hBullet[9];
Is the file a .cpp? Do you have any other errors? Is this all in one file?
The code itself is fine. I have just checked.
Zitat:
Zitat von head_54us
lol, i figured it out. i was declaring bullet as an image as well. i changed that, and it fixed it, BUT, now im getting linkning errors:
i haven included graphics.h in my main file as well as my makefile. here is my make file:Code:main.o: In function `main':
main.cpp:(.text+0xe8): undefined reference to `initGraphics()'
main.cpp:(.text+0xf4): undefined reference to `loadImage(char const*)'
main.cpp:(.text+0x108): undefined reference to `loadImage(char const*)'
main.cpp:(.text+0x11c): undefined reference to `loadImage(char const*)'
main.cpp:(.text+0x140): undefined reference to `flipScreen()'
collect2: ld returned 1 exit status
make: *** [hello.elf] Error 1
whats wrong now??? (btw, is it just me, or does cygwin seem to hate me?)Code:TARGET = BulletTest
OBJS = main.o graphics.o framebuffer.o
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LIBS = -lpspgu -lpng -lpsppower -lz -lm
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = TestOne
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
It is saying that the functions have been declared and used but not defined. Are they in graphics and/or framebuffer source files?
Zitat:
Zitat von head_54us
yep. all in there
I'm uhh... Begining this C++ stuff. Need some help here. Just making a little thingy to see what I know. :\
#include <iostream.h>
int main() {
int theYear = 2006;
return 0;
}
int main() {
int myBirthYear = 1992;
return 0;
}
int main() {
int myAge = << theYear - myBirthYear << endl;
cout << "My age is " << myAge << endl;
return 0;
}
-= Double Post =-
Oh. And I don't understand the compiler errors on Dev-Cpp... :\
I know nothing of C++. But from coding C on the PSP, something tells me it should be more like that.Code:#include <iostream.h>
int main() {
int theYear = 2006;
int myBirthYear = 1992;
int myAge = << theYear - myBirthYear << endl;
cout << "My age is " << myAge << endl;
return 0;
}
Wow. I just realized how stupid I am. Even though it doesn't work. Need more help please lol.
-= Double Post =-
I think my only problem is subtracting. I didn't know how so I took a guess. Someone tell me how to subtract?
its ok. my first program in C was similar to this:Zitat:
Zitat von Cheez Pirate
Code:int 5;
void main(x)
{
print("what is int?" " int is int")
end
}
BTW, i got my problem fixed.
Try that.Code:#include <iostream>
using namespace std;
int main () {
int currentYear, myBirthYear;
int myAge;
currentYear = 2006;
myBirthYear = 1992;
myAge = currentYear - myBirthYear;
cout << myAge;
return 0;
}
Oh. Ok, hang on. By the way. What's the difference between C, and C++?
I edited the code because I seen a mistake. So if it doesn't work, try the new code. And the only only difference between them is syntax. It's the only difference between all languages. They all work the same way. You just have to know the 'words' the language should be written in.Zitat:
Zitat von Cheez Pirate
Thanks. That worked! And I understand it too. Thanks a lot!
I think the problem was that you forgot using namespace std;. But as I said, I'm no expert.
:o Also. Is there a main loop? I run it and it disapears right away.
I don't know. I just modified this code from a tutorial.
// operating with variables
#include <iostream>
using namespace std;
int main ()
{
// declaring variables:
int a, b;
int result;
// process:
a = 5;
b = 2;
a = a + 1;
result = a - b;
// print out the result:
cout << result;
// terminate the program:
return 0;
}
Zitat:
Zitat von Cheez Pirate
do this:
that basically says, "wait forever." :)Code:int main() { // your main function //
while (1) {
// the printing stuff here//
sceDisplayWaitVblankStart();
flipScreen();
}
sceKernelSleepThread();
return 0;
}
Ok. Guess I gotta get rid of "return 0;"
-= Double Post =-
:D Or that lol.
propel, stop leading him towards computer C++. i understand that your trying to help, but comp. and psp stuff is very different. for one, in psp, you dont need to put:Zitat:
Zitat von Propel
and you need a loop, just like in lua.Code:using namespace std
He's coding for the PC.Zitat:
Zitat von Grimfate126
Zitat:
Zitat von Propel
then why is it in this section?
Because it's the C/C++ Development thread. Maybe he's practicing coding for the PSP.Zitat:
Zitat von Grimfate126
Ya. I'm using it on both.
-= Double Post =-
Like learning both at the same time. Functions for PSP, and comp.
ok. im just warning you that you may get confused. try to learn one thing. then use it for another. (ur choice.)Zitat:
Zitat von Cheez Pirate
lol ok. Well I saved the PSP main loop in a txt doc. Now I need the loop for the computer if there is one. Coz when I run it. It still shuts itself off after like a milisecond.
Zitat:
Zitat von Cheez Pirate
i dont know much about comp c++. use google.
Just put system("PAUSE"); right before the return 0;
Oh, and you don't have to put using namespace std; you simply can write std::cout, std::cin ... instead.
No Idea, but tell him this: < !!Zitat:
Zitat von Bronx
Seriuosly? Why is that?Zitat:
Zitat von homer
I wouldn't do that. That's just settign yourself up towards failure. Just learn c. And I really wouldn't recommend learning on the pc, seeing as it's actually easier to code on the psp then the pc. :PZitat:
Zitat von Cheez Pirate
Zettablade: That is a matter of opinion. I find it a hell of a lot easier to program something with C++ then C. Strip away all the libraries and I pick C++ with classes, strict type safety, const correctness and template metaprogramming over C structs and macros any day of the week.
I also disagree about learning straight away on a PSP/DS/any hardware platform. Trying to get your head round the SDK/toolchain AND learning how to program at the same time can be extremely difficult to do for a new programmer. However, I agree that you should only develop for one platform then move on to the next.
I think that's what youresam tried to tell you too.Zitat:
Zitat von Lukeson
The reason it's faster is because it doesn't have to go through as many pixels. Just think about it, the large image contains 480*272 pixels, while the arrows contain like 5*5+5*5+5*5 ...
i c... (even though the image is only 5*260, still true)
In addition, you are using less memory to store the image of one arrow.
Getting an error google doesn't have an answer for:
I got a round fuction from http://www.cs.tut.fi/~jkorpela/round.html . I included <limits.h> as written on the page. The error I get is
The code isZitat:
main.c:(.text+0x2c): undefined reference to `assert'
main.c:(.text+0x4c): undefined reference to `assert'
Code:long round(double x) {
assert(x >= LONG_MIN-0.5);
assert(x <= LONG_MAX+0.5);
if (x >= 0)
return (long) (x+0.5);
return (long) (x-0.5);
}
You need to #include <assert.h> where you use the function assert. (#include <cassert> if you are using C++).