 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Stalin
Joined: 05 Jun 2006 Posts: 3
|
Posted: Tue Dec 23, 2008 3:48 pm Post subject: OSLib basic rts engine [broken] |
|
|
Okay,
So I have this program I'm trying to get to work, it is my attempt at a basic RTS type engine. I was able to make it draw one unit, select it and use joystick to draw selection box. (I know truly amazing things)
I changed to classes and made a little loop to where its supposed to draw 10 units on the screen and I should be able to select them (this is just to test some things out)
I got the current version to compile, tho all that happens is it draws one unit on the screen and it randomly jumps, this causes two odd questions, first being is there a problem with my classes to where its not passing the 10 objects into the drawing phase, second how did i mess it up to where it is rerolling the coordinates when the one call to reset the coordinates is outside the main loop.
Finally, it has been about 2 months since I have worked on this, I was having a problem with it not compiling due to some char problems between the various functions (oslib functions to draww things) so now I cannot even get it to compile.
I know its asking alot but if I could get some serious help with this.
Thanks
Stalin
My Error MSG:
| Code: | stalin@porta-commy:~/Desktop/psp/rts$ make
psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -G4 -Wall -O2 -I. -I/usr/local/pspdev/psp/sdk/include -G4 -Wall -O2 -fno-exceptions -fno-rtti -D_PSP_FW_VERSION=150 -c -o main.o main.cpp
main.cpp: In function ‘int main()’:
main.cpp:45: warning: deprecated conversion from string constant to ‘char*’
main.cpp:39: warning: ‘stloc.ptBoxLocation::x’ may be used uninitialized in this function
main.cpp:39: warning: ‘stloc.ptBoxLocation::y’ may be used uninitialized in this function
psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -G4 -Wall -O2 -I. -I/usr/local/pspdev/psp/sdk/include -G4 -Wall -O2 -fno-exceptions -fno-rtti -D_PSP_FW_VERSION=150 -c -o object.o object.cpp
object.cpp: In constructor ‘CObject::CObject(const char*)’:
object.cpp:8: warning: deprecated conversion from string constant to ‘char*’
object.cpp: In member function ‘void CObject::freeImage()’:
object.cpp:15: error: ‘oslFreeImage’ was not declared in this scope
object.cpp: In member function ‘void CObject::loadImage(const char*)’:
object.cpp:23: error: invalid conversion from ‘const char*’ to ‘char*’
object.cpp:23: error: initializing argument 1 of ‘OSL_IMAGE* oslLoadImageFile(char*, int, int)’
object.cpp: At global scope:
object.cpp:31: error: prototype for ‘void CObject::drawImage() const’ does not match any in class ‘CObject’
object.h:20: error: candidate is: void CObject::drawImage()
object.cpp: In member function ‘bool CObject::isSelected(ptBoxLocation)’:
object.cpp:46: error: ‘stloc’ has incomplete type
object.h:15: error: forward declaration of ‘struct ptBoxLocation’
object.cpp: In member function ‘void CObject::showSelected()’:
object.cpp:57: error: ‘rine’ was not declared in this scope
make: *** [object.o] Error 1
|
Attached is everything I have for the program.
www.nilats.net/stalin-prg.zip |
|
| Back to top |
|
 |
PosX100
Joined: 15 Aug 2007 Posts: 98
|
Posted: Tue Dec 23, 2008 7:52 pm Post subject: Re: OSLib basic rts engine [broken] |
|
|
| Stalin wrote: | Okay,
So I have this program I'm trying to get to work, it is my attempt at a basic RTS type engine. I was able to make it draw one unit, select it and use joystick to draw selection box. (I know truly amazing things)
I changed to classes and made a little loop to where its supposed to draw 10 units on the screen and I should be able to select them (this is just to test some things out)
I got the current version to compile, tho all that happens is it draws one unit on the screen and it randomly jumps, this causes two odd questions, first being is there a problem with my classes to where its not passing the 10 objects into the drawing phase, second how did i mess it up to where it is rerolling the coordinates when the one call to reset the coordinates is outside the main loop.
Finally, it has been about 2 months since I have worked on this, I was having a problem with it not compiling due to some char problems between the various functions (oslib functions to draww things) so now I cannot even get it to compile.
I know its asking alot but if I could get some serious help with this.
Thanks
Stalin
My Error MSG:
| Code: | stalin@porta-commy:~/Desktop/psp/rts$ make
psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -G4 -Wall -O2 -I. -I/usr/local/pspdev/psp/sdk/include -G4 -Wall -O2 -fno-exceptions -fno-rtti -D_PSP_FW_VERSION=150 -c -o main.o main.cpp
main.cpp: In function ‘int main()’:
main.cpp:45: warning: deprecated conversion from string constant to ‘char*’
main.cpp:39: warning: ‘stloc.ptBoxLocation::x’ may be used uninitialized in this function
main.cpp:39: warning: ‘stloc.ptBoxLocation::y’ may be used uninitialized in this function
psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -G4 -Wall -O2 -I. -I/usr/local/pspdev/psp/sdk/include -G4 -Wall -O2 -fno-exceptions -fno-rtti -D_PSP_FW_VERSION=150 -c -o object.o object.cpp
object.cpp: In constructor ‘CObject::CObject(const char*)’:
object.cpp:8: warning: deprecated conversion from string constant to ‘char*’
object.cpp: In member function ‘void CObject::freeImage()’:
object.cpp:15: error: ‘oslFreeImage’ was not declared in this scope
object.cpp: In member function ‘void CObject::loadImage(const char*)’:
object.cpp:23: error: invalid conversion from ‘const char*’ to ‘char*’
object.cpp:23: error: initializing argument 1 of ‘OSL_IMAGE* oslLoadImageFile(char*, int, int)’
object.cpp: At global scope:
object.cpp:31: error: prototype for ‘void CObject::drawImage() const’ does not match any in class ‘CObject’
object.h:20: error: candidate is: void CObject::drawImage()
object.cpp: In member function ‘bool CObject::isSelected(ptBoxLocation)’:
object.cpp:46: error: ‘stloc’ has incomplete type
object.h:15: error: forward declaration of ‘struct ptBoxLocation’
object.cpp: In member function ‘void CObject::showSelected()’:
object.cpp:57: error: ‘rine’ was not declared in this scope
make: *** [object.o] Error 1
|
Attached is everything I have for the program.
www.nilats.net/stalin-prg.zip |
Lol , again someone's asking for basic programming assistance...
Well , i'll help you a bit this time , since i have plenty of time
to bitch :)...
| Code: |
warning: deprecated conversion from string constant to ‘char*’
|
You're passing Const char* to a function that takes as parameter char*.
FFS
| Code: |
In member function ‘void CObject::loadImage(const char*)’:
|
same s(it ...
| Code: |
object.cpp:15: error: ‘oslFreeImage’ was not declared in this scope
|
You must have typed the function name incorrectly.
wtf
| Code: |
object.cpp:31: error: prototype for ‘void CObject::drawImage() const’
does not match any in class ‘CObject’
|
Probably implementantion is different from interface.Check the header.
Also if drawImage() handles pointers , remove the const keyword...
| Code: |
object.cpp:46: error: ‘stloc’ has incomplete type
object.h:15: error: forward declaration of ‘struct ptBoxLocation’
|
Some unknown structure.
| Code: |
object.cpp:57: error: ‘rine’ was not declared in this scope
|
...self explanatory... |
|
| Back to top |
|
 |
Stalin
Joined: 05 Jun 2006 Posts: 3
|
Posted: Wed Dec 24, 2008 6:29 am Post subject: |
|
|
found out that with the oslImageLoadFile it is odd way it was programmed and to get it working i needed to load it as "oslLoadImageFile(const_cast<char*>(imagename), OSL_IN_RAM, OSL_PF_5551);"
I have it working now, needed to disable the selection checking, i'm obviously NOT passing the structure into the class to check for each object incorrectly;
It is still incorrectly drawing the 10 objects, its simply drawing one unit on the screen in one location if someone could help with that I'd be very greatful.
Thanks
Stalin
Updated ZIP with working code and eboot:
www.nilats.net/stalin-rts.zip
[/i] _________________ www.nilats.net |
|
| Back to top |
|
 |
Stalin
Joined: 05 Jun 2006 Posts: 3
|
Posted: Wed Dec 24, 2008 1:00 pm Post subject: |
|
|
turns out the random numbers for coordinates where not actually random, more so they were just producing the same number 10x so it was drawing all 10 objects in the same area.
When passing the check, for wether or not a specific unit is selected i was using a structure to do the check. I am obviously doing it wrong becqause i cannot get the structure data to pass into the class to do the check to see if the unit is seleccted or not.
Can anyone either help me with this or... could someone give me a different approach to doing this which might work better?
thanks,
Stalin _________________ www.nilats.net |
|
| Back to top |
|
 |
foebea
Joined: 23 Mar 2007 Posts: 9
|
Posted: Wed Dec 31, 2008 6:20 am Post subject: |
|
|
My advice is to place a square in the center of the screen and call it origin. your other squares are plus or minus origin. So you define originx as equal to 200 and originy as equal to 140 or so. Then define another set of variables for x and y offsets, for example 20 if your squares are 20x20 pixels.
Now just place the origin, then place (origin + (offsetx*2)),(origin + (offsety*1)). That should put each square right next to each other, and if you place it all in a loop you can fill out a massive map of squares in only a few lines of code.
Basically each square could now be addressed in an array. like tree is in [-10,30] and house is in [4,2] and your selection is on [10,4]. I find it is easiest if whatever square your selection is currently on is recognized as the center square, and the actions are determined by how many units from origin he is.
Hope this helps some. I have done something kind of similar and for random generation of landscape this makes it much easier than plotting the entire map out manually, pixel by pixel. |
|
| Back to top |
|
 |
|
|
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
|