Nope, no such luck unfortunatly.
-Aura
Printable View
Nope, no such luck unfortunatly.
-Aura
Judas - Are you aware of hte relationship between pointers and arrays...
TMNT - In my Kitten Cannon game, you'll notice there's more then one blood splatter on screen (i think i specified 22 max on screen in the constants..) but anyways in your case, i recommend making a bullet structure or class. But to put it simply, something like this (i won't give you exact working code, learn from this then apply it to your situation ;))
This is untested and I wrote it up real quick, however it should work. You should notice some drastic changes that greatly improve readability and gameplay, one of which completely removes your whole fire delay thing for rapid fire - OSlib has a built in autokey repeat delay. Please look at the documentation else you'll keep hurting yourself ;)Code:const int NUM_BULLETS_ON_SCREEN = ?;
const int BULLET_SPEED = ?;
typedef struct
{
int iX, iY, iDamage, iSpeed;
bool bVisible;
} Bullet;
OSL_IMAGE *imgBullet = NULL;
Bullet sBullet[NUM_BULLETS_ON_SCREEN];
int iCurrentBullet = 0;
int iNumActiveBullets = 0;
void LoadBullet()
{
if (imgBullet)
oslDeleteImage(imgBullet);
imgBullet = oslLoadImageFilePNG("bullet.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
oslAssert(imgBullet);
// 0 - initial delay until repeat
// 30 - were running at 60 FPS, so 30 waits 1/2 a second per shot
oslSetKeyAutorepeat(OSL_KEYMASK_CROSS, 0, 30);
}
void UnloadBullet()
{
if (imgBullet)
oslDeleteImage(imgBullet);
imgBullet = NULL;
}
void InitBullets()
{
for (int i = 0; i < NUM_BULLETS_ON_SCREEN; i++)
{
sBullet[i].iX = 0;
sBullet[i].iY = 0;
sBullet[i].iDamage = 0;
sBullet[i].iSpeed = 0;
sBullet[i].bVisible = false;
}
iCurrentBullet = 0;
iNumActiveBullets = 0;
}
void CreateBullet(int posx, int posy)
{
sBullet[iCurrentBullet].iX = posx;
sBullet[iCurrentBullet].iY = posy;
sBullet[iCurrentBullet].iDamage = ?;
sBullet[iCurrentBullet].iSpeed = BULLET_SPEED;
sBullet[iCurrentBullet].bVisible = true;
iCurrentBullet++;
}
void Input()
{
oslReadKeys();
if (osl_keys->pressed.cross)
{
CreateBullet(player.x,player.y);
}
move player blah...
}
void UpdateBullets()
{
iNumActiveBullets = 0;
for (int i = 0; i < NUM_BULLETS_ON_SCREEN; i++)
{
if (sBullet[i].bVisible)
{
sBullet[i].iX += sBullet[i].iSpeed;
if (sBullet[i].iX > SCREEN_WIDTH)
{
sBullet[i].bVisible = false;
}
else if(BulletPlayerCollision(sBullet[i])
{
bullet player collision is occuring...
player.health -= (sBullet[i].iDamage);
}
else
{
iNumActiveBullets++;
}
}
}
}
void DrawBullets()
{
for (int i = 0; i < NUM_BULLETS_ON_SCREEN; i++)
{
if (sBullet[i].bVisible)
{
imgBullet->x = sBullet[i].iX;
imgBullet->y = sBullet[i].iY;
oslDrawImageSimple(imgBullet);
}
}
}
Awesome dude! The thing is, everytime i ask someone about rapidfire, they just give me code. Could you explain the logic behind that? And what is "bool"?
The logic behind the rapid fire code there is all in the built in autorepeat feature in OSlib. you'll notice that when loading the bullet image (LoadBullet) im setting a key repeat for the CROSS button so that it is automatically 'pressed' again every 1/2 seconds if you are holding it down.
As for the bool thing, it's a data type - google is your friend ;)
Oh, thanks. But how do you let your image (weapon) blit, and then blit again (on the screen at the same time), each with independent x and y coordinates?
Have you looked at my draw function? It does exactly what you just asked...
It loops through all the bullets, if a bullet is visible, it draws the bullet image at the bullet's position. Efficient and works great, what's the problem?
Check your PM box ;)Zitat:
Zitat von Auraomega
Zitat:
Zitat von cruisx
anyone? please help, i have been busy all week and i wont be able to sit down and look at the code again untill later tonight so i havent had time to figure this problem out =\.
Im working on a little project and I was wondering how would one fade in and fade out an image using OSlib(2.10)?
bnc - Check your documentation ;)
Use:
oslSetAlpha(OSL_FX_ALPHA, transparency value of anything drawn)
Example: use this as an intro screen if you want - it'll fade the image you pass to it in and out depending on the speed you pass it, i prefer 0.8f as the speed ;)
EDITCode:void FadeInOut(OSL_IMAGE *image, float speed)
{
float i = 0.0f;
int fadingIn = 1;
while (!osl_quit)
{
// start drawing
oslStartDrawing();
// clear screen black
oslClearScreen(RGB(0,0,0));
// set the alpha of anything drawn now
oslSetAlpha(OSL_FX_ALPHA, i);
// draw our image
oslDrawImage(image);
// end drawing
oslEndDrawing();
// end frame (flip draw/display buffers) sync's audio too
oslEndFrame();
// sync frames
oslSyncFrame();
// if were fading out AKA transparency 255 -> 0
if (fadingIn)
{
// add speed to transprency since the alpha is being set
i += speed;
// if i has reached 255 AKA the image is completely transparent now
if (i > 255.0f)
{
// were not fading out anymore
fadingIn = 0;
}
}
else // if were fading in
{
// subtract from the transparency
i -= speed;
// if the transprency is 0 again AKA completely visible
if (i < 0)
{
// break the loop and continue the program
break;
}
}
}
}
Gah sorry for the formatting - it got messed up when copy&pasting.since my tabs are 2 spaces, on here they're 4 :S
k guys been a way a little while learning more about opengl and stuff anyways i'm here because i have a couple of questions that i can't make sense of
anyways here's the question:
i'm building something to load in .x txt files and i have no idea how to make sense of the frametransformationmatrix
now than i've determined, which wasn't hard:Code:FrameTransformMatrix {
0.500000, -0.853553, -0.146447, 0.000000,
0.707107, 0.500000, -0.500000, 0.000000,
0.500000, 0.146447, 0.853553, 0.000000,
0.000000, 0.000000, 0.000000, 1.000000;;
}
0.500000, -0.853553, -0.146447, 0.000000,
0.707107, 0.500000, -0.500000, 0.000000,
0.500000, 0.146447, 0.853553, 0.000000,
is part of the rotation however this is where i get beyond confused:
in my model making program, i set all 3 axis's to 45 degrees and it gives me back what i posted above, can any help me get it so i can understand how to translate those numbers back into their respective 45 degree's which they were set to before being exported
also note:
when rotated by 45 degrees on only the z axis these are the numbers i get backCode:FrameTransformMatrix {
0.707107, -0.000000, -0.707107, 0.000000,
0.000000, 1.000000, -0.000000, 0.000000,
0.707107, -0.000000, 0.707107, 0.000000,
0.000000, 0.000000, 0.000000, 1.000000;;
}
Read up on matrices: http://en.wikipedia.org/wiki/Transformation_matrix
Also give careful attention to what transformations effect which parts of the matrix.
yes iwn i've already read up on that however i can't seem to follow it trust me i'm not stopping here without having already done some research however it all seems to be over my head i mostly need to see an example of how it is used in a tad bit simpler principle
woot i got it=-)
after a few more hours of research i finally understand matrix rotations better all be it not the best but enough to get me by for now=-)....well at least if i can use it for animation=-).....i hope=-(
arg god dam quaternions=-(
I'm having some issues with stubs, I've been talking to another developer but we are both at a loss as to the cause.
My errors when I try compiling:
My stub is:Zitat:
moduleMgrForKernel.s: Assembler messages:
moduleMgrForKernel.s:5: Error: unrecognized opcode `stub_start "ModuleMgrForKernel",0x40 090000,0x00030005'
moduleMgrForKernel.s:6: Error: unrecognized opcode `stub_func 0x6723BBFF,sceKernelLoadM oduleForLoadExecVSHMs1'
moduleMgrForKernel.s:7: Error: unrecognized opcode `stub_func 0x49C5B9E1,sceKernelLoadM oduleForLoadExecVSHMs2'
moduleMgrForKernel.s:8: Error: unrecognized opcode `stub_func 0xF07E1A2F,sceKernelLoadM oduleForLoadExecVSHMs4'
moduleMgrForKernel.s:9: Error: unrecognized opcode `stub_end '
All other stubs I use work fine, but they were created from export files, this was manually made. Any help would be greatly aprechiated.Code:.set noreorder
#include "pspstub.s"
STUB_START "ModuleMgrForKernel",0x40090000,0x00030005
STUB_FUNC 0x6723BBFF,sceKernelLoadModuleForLoadExecVSHMs1
STUB_FUNC 0x49C5B9E1,sceKernelLoadModuleForLoadExecVSHMs2
STUB_FUNC 0xF07E1A2F,sceKernelLoadModuleForLoadExecVSHMs4
STUB_END
-Aura
Try renaming "moduleMgrForKernel.s " to "moduleMgrForKernel.S"
:)
Grr it worked, that was all the problem was... Does having a capital extention affect any other file types, for future reference?
-Aura
I'm trying to make just a small thing (just for learning purposes, and maybe a laugh or two from friends) I finally got it to compile but when it did it wouldn't display the image.
I am new to C, and I'm also trying to do this in the 3.XX kernel.
Main.c
MakefileCode:#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspgu.h>
#include <png.h>
#include <stdio.h>
#include "graphics.h"
#define printf pspDebugScreenPrintf
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
PSP_MODULE_INFO("Image Display Program", 0, 1, 0);
PSP_HEAP_SIZE_KB(20480);
/* 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* bsod;
pspDebugScreenInit();
SetupCallbacks();
initGraphics();
sprintf(buffer, "bsod.png");
bsod = loadImage(buffer);
if (!bsod) {
//Load Failed
printf("Messed up the code, go fix it\n");
} else {
int x = 0;
int y = 0;
sceDisplayWaitVblankStart();
while (x < 480) {
while (y < 272) {
blitAlphaImageToScreen(0 ,0 ,480 ,272, bsod, x, y);
y += 32;
x += 32;
y = 0;
}
flipScreen();
}
sceKernelSleepThread();
return 0;
}
}
Thanks in advanced for your helpCode:TARGET = hello
OBJS = main.o graphics.o framebuffer.o
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LIBS = -lpspgu -lpng -lz -lm
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Windows Vista
BUILD_PRX = 1
PSP_FW_VERSION = 390
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
Gah I really do hate yeldarb's tutorial on that lol - too much logic for them at that level ;)
But anyways - you just want to forever display that image right?
So what you want to do is load hte image, draw the image, flip draw/display buffers then sleep thread so make main() look something like:
Code:int main()
{
// init the debug screen
pspDebugScreenInit();
// setup callbacks
SetupCallbacks();
// init the graphics
initGraphics();
// declare our image variable, assign to null initially
Image* bsod = NULL;
// load the imshr
bsod = loadImage("bsod.png");
// if it failed to load
if (!bsod)
{
printf("Failed to load 'bsod.png'");
}
else
{
// blit image
blitAlphaImageToScreen(0, 0, 480, 272, bsod, 0, 0);
// wait for vsync
sceDisplayWaitVblankStart();
// flip the display/draw buffers
flipScreen();
}
// make this thread sleep forever, still home->quit is available
sceKernelSleepThread();
return 0;
}
Wouldn't that be better (according to Yaustar)?Code:// if it failed to load
if (bsod == NULL)
{
printf("Failed to load 'bsod.png'");
}
Define 'better'. !bsod means it isn't pointing to an address meaning it's null (watch me be corrected by some awkward exception :P). For readability probably too but hey preferences.
Thank you very much, worked perfectly.Zitat:
Zitat von SG57
There is one obscure case in C where NULL isn't always 0. In C++ IIRC, the standard is NULL is ALWAYS 0. So in C if NULL is not zero:Zitat:
Zitat von SG57
Code:int * pInt = NULL;
if( !pInt )
{
// This code will execute because pInt is non-zero
}
Well for me I'm in the clear if you recall correctly ;)
I'm an math idiot. If I have an object needs to travel from point A to point B. The path look something like this(along a spline). How to calculate and code?
Thx.
http://lh5.ggpht.com/Snowymydog/SAgm...7LI/spline.jpg
How come no matter what I do, I can't seem to get the psp slim tv-out working?
I've included the stub "pspDveManager.S" and have created a 'dummy' function within my main.cpp "int pspDveMgrSetVideoOut(int, int, int, int, int, int, int);", just like the sample did.
It compiles the code fine, but once it hits the finalization of the compiling I get, 'Undefined Reference to pspDveMgrSetVideoOut(int, int, int, int, int, int, int)' @ line 330 which is the line where I declared that function.
What else do I do? I don't understand how the sample works but my code doesn't?
(The sample is at http://dl.qj.net/Fullscreen-TV-out-f...4864/catid/151)
So After getting the Image to work and buttons and a few other things I decided to try out the Message dialogs (like the official ones). I finally got it to compile but whenever i go to run it it just flashes the text and then the screen stays blank.
Here's my code (sorry if it's horribly formatted)
Spoiler for Code:
I'm positive i have all of the libraries and callbacks.
Also if it matter's I'm trying to do this on my slim so 3.xx kernel.
The problem is probably some stupid mistake, or just something real small that i missed but I've been looking all day and i couldn't find anything.
Thank you to anyone who can i help.
Put it in a loop, else it'll only check all of that once - the sleep thread call in there is what's stopping it from exiting right now, so leave the return and i guess the sleep thread call outside the loop (although it's not really necessary :S)
ok thank you very much.Zitat:
Zitat von SG57
k hey everone back with another question about .x files
now than i've moved from my transformation problems and have been able to load a model, animate it(note this method is without bones), texture, give it normals, basically i have the model good and loaded
now than here's the problem: skinweights
i understand the following:
that's all fine and dandy no problem understanding that after some research into it(yea power to google!!) now than i also understand that this requires manipulating the vertex themselfs....this is where the problem lies:Code:SkinWeights {
//name of bone and bone's animation in relation
"Bone-3";
//number of vertices affected by this bone
112;
//the vertex's that are affected
69,
16,
72,
etc
//how much the vertex is affected by the bone
0.466086,
0.466086,
0.435675,
etc
so as u can see rotating a vertex is my problem...i understand rotating an whole object, which i use glRotatef(angle, amountx, amounty, amountz), however writing the function myself is the problem am i to translate to the center of the object than calculate the rotation than reposition the vertex?!?!Code:
Animation Animation3 {
//object's name which is located(this occurence it's a bone)
{Bone-3}
AnimationKey {
//2 = movement
2;
//7 keyframes
7;
//movement...no problem here i can move an vertex all day long
0; 3; -0.000000, 0.999994, 0.002683;;,
5; 3; -0.000000, 0.827936, -0.409556;;,
10; 3; 0.000000, 0.412317, -0.573280;;,
15; 3; -0.000000, 0.833326, -0.404204;;,
20; 3; -0.000000, 0.999721, 0.017872;;,
25; 3; -0.000000, 0.840180, 0.397187;;,
30; 3; -0.000000, 0.467647, 0.571981;;;
}
AnimationKey {
//0 = rotation
0;
//7 keyframes
7;
//rotation...here's the problem(more explanation below)..note that the animations are quaterions(misspelled i know)
0; 4; 0.999997, -0.002339, -0.000000, 0.000000;;,
5; 4; 0.921942, 0.387329, 0.000000, 0.000000;;,
10; 4; 0.698280, 0.715824, 0.000000, 0.000000;;,
15; 4; 0.924487, 0.381214, 0.000000, -0.000000;;,
20; 4; 0.999879, -0.015585, -0.000000, 0.000000;;,
25; 4; 0.927713, -0.373294, -0.000000, 0.000000;;,
30; 4; 0.732010, -0.681294, -0.000000, 0.000000;;;
}
AnimationOptions {
0;
0;
}
}
anyhelp or pointers on how to to achieve this would be AWSOME!!
and thx's every1=-)
You don't need to do it in software.
Look at the morphskin sample that comes with the SDK.
Particularly the sceGuMorphWeight() function and others.
i'm not doing this with the psp, at least not at first anyways
I donot exactly understand the purpose of empty semicolon ended while loop :confused:Code:while (something) { /*nothing here*/ };
someother statement;
quick question on drawing an circle...which i think i may have realized a faster way as i write this.....anyways
currently the way i'm drawing a circle is:
^^now than for one or two circles not bad however a multitude of circles and u see a huge slowdownCode:#include <oslib/oslib.h>
#include <math.h>
#define PI (first several digits go here)
void DrawPixel(float x, float y, osl_color color){
oslDrawFillRect(x, y , x+1, y+1, color);
}
void DrawCircle(int x, int y, int radius, osl_color){
for(int i=0;i<360;i++){
float tx = x + sinf(i*(PI/180))*radius);
float ty = y - cosf(i*(PI/180))*radius);
DrawPixel(tx, ty, color)
}
}
i've changed the function
toCode:void DrawCircle(int x, int y, int radius, osl_color){
for(int i=0;i<360;i++){
float tx = x + sinf(i*(PI/180))*radius);
float ty = y - cosf(i*(PI/180))*radius);
DrawPixel(tx, ty, color)
}
}
so that does show a major increase in speed but not the bestCode:void DrawCircle(int x, int y, int radius, osl_color){
for(int i=0;i<360;i+=30){
float tx = x + sinf(i*(PI/180))*radius);
float ty = y - cosf(i*(PI/180))*radius);
DrawPixel(tx, ty, color)
}
}
would it be faster and this is the idea i just thought of to:
draw the circle to an empty image than just displaying the image?
thanks every1
They're doing it wrong.Zitat:
Zitat von Mr305
Perfectly valid, even if kinda hard to read at times.Code:while (something_that_affects_state);
OK this is not for PSP, I am learning C++ still but have hit a problem with random numbers. I am using Dev C++, with begining ++ Game Programming (this uses Dev C++). The program is meant to be like a dice when rolled, a random number is produced and then modulised by 6 to make it a dice number. However when I run this I only get 6 everytime I run the program. Here is the code.
Code:#include <cstdlib>
#include <iostream>
#include <ctime>
using namespace std;
int randomnumber = rand(); //generates a random number
int die = (randomnumber % 6) + 1; //get a number between 1 and 6
int main()
{
srand(time(0)); //seed a random number based on current time
cout << "You got a " << die << endl;
cin.get();
return 0;
}
slicer - Please format your code, your how old now? (in all seriousness)
Anyways, ya something like hwat you said might be better considering your slow down is due to those 2 calculations * 360 times * number of circles to draw. This will only run those 2 calculations once then just scale the image to the radius specified.
Example:
Haven't tested it however it should work. If it doesn't tell me the outcome, i have a few other filtering techniques to color it to the desired color....Code:OSL_IMAGE *pEllipse = NULL; // internally used, don't directly use this anywhere
// run this function anywhere just once before drawing hte circle (usually the loading resources part of a game)
void Initialize()
{
if (pEllipse != NULL)
oslDeleteImage(pEllipse);
// create image
pEllipse = oslCreateImage (512, 512, OSL_IN_VRAM, OSL_PF_8888)
oslAssert(pEllipse);
// clear to alpha
oslClearImage(pEllipse, RGBA(0, 0, 0, 255));
// set the draw buffer to the new image
oslSetDrawBuffer(pEllipse);
// draw the circle on it, radius = 1/2 dimensions
for (int i = 0; i < 360; i++)
{
int tmpX = oslCosi(i, 256) + 256; // why you don't use OSlib's math functions i dont know...
int tmpY = oslSini(i, 256) + 256; // these use the VFPU, takes the angle as a degree and multiplies it by the magnitude and returns an integer
// does all the stuff you were doing but faster and more readable ;)
oslDrawFillRect(tmpX, tmpY, tmpX + 1, tmpY + 1, RGB(255,255,255)); // draw it white
}
// set the draw buffer back to the default
oslSetDrawBuffer(OSL_DEFAULT_BUFFER);
}
void DrawCircle(int x, int y, int radiusX, int radiusY, OSL_COLOR color)
{
pEllipse->x = x - radiusX; // set the position of the image
pEllipse->y = y - radiusY; // "
pEllipse->stretchX = radiusX * 2; // set the width of the ellipsoid
pEllipse->stretchY = radiusY * 2; // set the height "
// store the current params
OSL_ALPHA_PARAMS *currentParameters = NULL;
oslGetAlphaEx(currentParameters);
// now we set a filter to convert the white part of the ellipsoid image
// (the circle part) to the color passed
oslSetAlpha(OSL_FX_ALPHA | OSL_FX_COLOR, color);
oslDrawImage(pEllipse); // draw it
// back to normal
oslSetAlphaEx(currentParameters);
}
Also, take a look here:
http://www.psp-hacks.com/forums/viewtopic.php?id=140324
leejames - It should always return 6 (well any value at that, just the same each time). Your initializing 'randomnumber' to a random number before setting a random seed. Try something like this (btw format your code or i'll have your head ;))
That'll work. However I recommend you avoid global variables where possible, not initialize variables to desired values, assign them later to desired values (that was your main problem here) and format your code (a lot of people don't like having to take the time and format your code then look for a problem so format before hand).Code:#include <cstdlib>
#include <iostream>
#include <ctime>
using namespace std;
int randomnumber = 0;
int die = 0;
int main()
{
srand(time(0));
randomnumber = rand();
die = (randomnumber % 6) + 1;
cout << "You got a " << die << endl;
cin.get();
return 0;
}
Try this:Zitat:
Zitat von leejames04
Try not to use globals unless absolutely neccessary, and seed before you randomize.Code:#include <cstdlib>
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
srand((unsigned)time(0)); //seed a random number based on current time
int randomnumber = rand(); //generates a random number
int die = (randomnumber % 6) + 1; //get a number between 1 and 6
cout << "You got a " << die << endl;
cin.get();
return 0;
}
Re-post.Zitat:
Zitat von Slasher
Anyone successfully get this working? How can I get it working?
EDIT: nvm I figured it out
Code:#ifdef __cplusplus
extern "C" {
#endif
int pspDveMgrCheckVideoOut();
int pspDveMgrSetVideoOut(int u, int mode, int width, int height, int x, int y, int z);
#ifdef __cplusplus
}
#endif
sry sg57 i'm so used to hitting tab to increase by a few spaces that when trying to type formated code here....well anyways, thanks that'll defiantly give me speed up i think i'm ganna re-write pixel attack anyways since my coding style has changed so much since the time that i wrote it anyways thanks a million this well rly help me=-)
plus i wanna try a few physic's tricks that i've learned to make it look far better
also i didn't use the oslcos and sin commands because they've given back undesired results before so i find going with sinf and cosf to give me the results i'm looking for
What do you mean undesired results lol
They take an angle in degrees and the radius size/magnitude. Returns the integer value of the sin/cos of that angle * the radius size/magnitude. It uses the vfpu for the calculations as well so a lot of calls to it should make a significant difference between math.h sinf/cosf and oslib's oslCos and oslSin...