Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Tigre Pablito

Pages: 1 ... 12 13 [14] 15
196
SFML projects / Re: My Sonic the Hedgehog game (goes fine, but need help)
« on: September 24, 2013, 10:18:48 pm »
Hi Ladies and Guys

Now I fixed the Alt + Tab crashing issue, as you told me, I tested it myself;
Also I fixed the Esc pressing (To quit the app) matter, now if you press Esc you return to Start screen, where if you press Esc you exit ... ( It seems to me or we re missing a SFML QuitApplication function? )

Ixrec, you saw the springs (or jumping pads) were invisible? and the flames the first boss throws too? It s very strange that ... on my PC, no object is invisible in my poor game ... Could it be a failure on the image files?

About porting SFML apps from 32 to 64 bit, I found out that what I needed to change was the SFML DLLs, the C# code is the same, actually I compiled the 32 bit version with x86 DLLs, and the 64 bit version with x64 DLLs,

32 bit download

https://www.dropbox.com/s/9ikj1kbm53oqpp3/Sonic%20the%20Hedgehog%20by%20Pablito.rar

64 bit download

https://www.dropbox.com/s/xm54luwk8wehynb/Sonic%2064%20bit%20by%20Pablito.rar

Source Code (fixed) (for both 32 and 64 bit)

https://www.dropbox.com/s/tzts0sy3s6hswj4/SOURCE%20CODE.rar

Those who want to compile the code, remember to add the SFML.NET DLLs to the References node, on the Solution Explorer, but the x86 if the system is 32 bit, or the x64 if it is 64 bit ... there they are in each game version, in the exe's folder

What I would like is that someone goes along up to the Zone 2 Act 2, beats it (Eggman at the end), and then tells me why, while trying to load Zone 3 Act 1, my hedgehog runs with a OutOfMemoryException ... obviously it is not a lack of memory, because I have 2 GB, ... and the blue screen, I put them to inform about the used memory (on each level, whose sizes are different), without success as seen ... as seen at finishing 2-2

The code about loading levels and that stuff can be found in the LEVEL subfolder from the source code
(I also tried using the GC, but no effect ... it should be a lost reference that remains anywhere, or a failure in the Image class (the Zone image files are quit big, and JPG), or a failure on the image files, ... or I don t know what)

Thank you all


197
General / Re: C++ SFML, Circular Movement - Help!
« on: September 23, 2013, 07:20:20 pm »
Did you do what I suggested? Please send the new fixed code, so I can see
It shouldn't fail ...

I'll try here again the main loop

let s supose speed = 40;

while (window.IsOpen())
{
    // FRAME THE GRAPHICS
    DrawGraphics();   // whatever it is

    // THE BALL MOVES AND BOUNCES
    for (int a = 0; a < 20; a++)
    {
        ballX += cos(radians(ballAngle)) * 2;
        ballY -= sin(radians(ballAngle)) * 2;

        if (DetectCircumpherenceCollision(ballX, ballY, bigCircleRadius))
            ballAngle = angleCirc(ballX, ballY, ballAngle, bigCircleRadius);
    }   

    // HERE speed = 40, n = 20, THEN speed / n = 2, as seen in the for() LOOP
    // THE GREATER n, BETTER, BUT NOT > speed

    // TIME RETARD
    //
}

Try this, and post the code so I can see
And don't worry, the program will work
Meanwhile I'll check out the paddle collision issue

198
General / Re: C++ SFML, Circular Movement - Help!
« on: September 23, 2013, 03:10:02 pm »
If I m not wrong, "fixed time step" means, that instead of the ball goes forward speed px and then test the circle line collision, you do something like this

for (a = 0; a < n; a++)
{
    ballX += cos(radians(ballAngle)) * speed / n;
    ballY -= sin(radians(ballAngle)) * speed / n;
   
    if (DetectCircumpherenceCollision(ballX, ballY, bigCircleRadius) == true)
    {
        ballAngle = angleCircle();
    }
}
n should be lower or equal than and an exact divisor of speed

this is, you part the number of px the ball scrolls per frame, in order that the collision detection is more exact, cos if not, supose the ball is 4 px from the border line, and you increase its trayectory in 8 px, what happens? the ball overpasses the circle line, and there are problems ...
with this trick, that aparently they called "fixed time step", it is like if the ball gave shorter steps, and it can bounce before ending the last of those shorter steps, in which case it scrolls the pending steps after having bounced and changed its angle, but in opposite way
that is, the collision will be tested n times instead o 1, along the distance the ball scrolls per frame, that will avoid that it overpasses the circle border line
(greater n, greater precission, in the most exact case, the shorter step's module is 1, that is n = speed)

what I called Radius, is the big circle radius, then I call ballRadius to the ball radius, but in the paddle collision function ...

About the reference signus, I'm not sure how it is in VS C++.NET, but in the ancient C/C++ it was:
(for example)
void swap(int *a, int *b)
{
    int temp = *a;
    *a = *b;       // indirection operator *, access the value
    *b = temp;
}

and you called the function

swap(&a, &b);   // passing the address with the reference operator &

But I think now, using the fixed timestep, it won't be necesary to use pointers in the fuction's args (that is used to modify the values referred by them)

Keep us alert of your game's progress, and tell me if you need something else
 :) ;) :D ;D 8)

199
SFML projects / Re: My Sonic the Hedgehog game (goes fine, but need help)
« on: September 23, 2013, 02:12:22 pm »
Maybe what was wrong was that I used the DLLs in the folder x86 from SFML.NET ... because my system is 32 bit, then in my PC it works
Now, I compiled a new copy of my program, with the DLLs that are in x64 folder ... (Oremos para que funcione en las PCs de 64 bit, en la mia de 32 NO lo hizo, quizas es una buena seƱal)

So, please, I invite those Ladies and Guys who have a 64 bit system to test my poor "Sonic 64 by Pablito" Version for 64 bit

https://www.dropbox.com/s/xm54luwk8wehynb/Sonic%2064%20bit%20by%20Pablito.rar

Then, we just were missing to solve the crash because of OutOfMemoryException,
from what I would appreciate your help,
Thank you

200
General / Re: C++ SFML, Circular Movement - Help!
« on: September 23, 2013, 12:32:10 pm »
Good morning!

I got scared, for a few moments, but, finally I found the problem

the function angleCircle() returns its value in degrees, I recommend also you assign the initial ballAngle in degrees, let s say, 60;

then, when you pass the argument to cos() and sin() functions, you should first convert the ballAngle degrees to radians,

please write this new function

double Radians(double degrees)
{
    return (degrees * PI / 180.0);
}

and now you can correct the lines

ballX += cos(ballAngle) * ..................

by

ballX += cos(Radians(ballAngle)) * ...................

Remember that always all the trigonometrical functions return their values and take their arguments that are angles, in radians; you can use degrees so that is easier for you to read and understand your program, but need to convert when calling these functions

Good luck, I m waiting for the fixed version!

Pablo

PS: I was able to run this and the previous you sent, thank to your help with the MS package

201
SFML projects / Re: My Sonic the Hedgehog game (goes fine, but need help)
« on: September 23, 2013, 11:40:54 am »
It's O.K., MiLord!

Here's the link to my poor Sonic's source code files
https://www.dropbox.com/s/tzts0sy3s6hswj4/SOURCE%20CODE.rar

These files just generates the executable, that needs the SFML DLLs and the DATA FILES folder to run
(if someone has difficulties in understanding the code, just inform, and I'll try to make it more legible, in all ways, such as longer variable names so they can be caught the idea what they are/do)

I think you (Ixrec) told me you were using Windows 8 64 bit ... I supose there must be a way to adapt a SFML app from 32 bit to 64 bit, I'll ckeck out, I think I remember that there is a SFML library version for both 32 and 64 bit ... but is it needed to recompile the program, or just copy the 64 bit DLLs to the folder where the exe is, to be able to run my game on a 64 bit system?

Maybe if you try to run my poor Sonic on a 32 bit system, it will run properly ...

Well:
* Please, if someone runs my program, tell me in what way it crashes
* If someone can help to solve my game's memory trouble, I will appreciate it very much
* So I will if you tell me how to adapt my poor game to different PCs, and OSs
* Welcome critics and suggestions to improve the app

The crash cause should be in the LEVEL subfolder files

Thanks!

Pablo

PS: I know very well I'll have to improve the graphics, and all the game; remember the power of each bubble/shield you can get from the TV items (the fire bubble impedes fire to hit your character, the magnetic one lets you jump higher)

202
SFML projects / My Sonic the Hedgehog game (goes fine, but need help)
« on: September 23, 2013, 07:06:18 am »
Hello, Ladies and Guys from SFML

I'm working on a Sonic the hedgehog game, cos I'm a fan of it, and Mario, since I was a child
By now, it works fine, has 4 Zones, 2 Acts each one, and has an interesting memory problem

Here's the link to download my poor Sonic (exe, dlls, and data files, in a .rar)
https://www.dropbox.com/s/9ikj1kbm53oqpp3/Sonic%20the%20Hedgehog%20by%20Pablito.rar

My system is Windows 7 Ultimate, 32 bit, and the program is written in C#

I would need to know these:
* Should I post a link to the source code? (I would have no problem)
* There's a problem in the app, it throws an Exception of the OutOfMemoryException class, when loading Zone3Act1; Is it allowded to ask help about that here? If it's not, please tell me where it is (I already asked in the Help->General, and nobody knew how to solve my bug); if it is, then I explain it below;

On each game level, the program calls the LoadZone?Act?() method, which loads 2 Images (.jpg that are there in the LEVELS subfolder), the level's foreground and background ... in some levels, by now the background is null ... the Images are local variables, that are passed to 2 Sprites[,] splitted into 1000x1000 Textures
First I built the Images in runtime, and saved them to files (Image.SaveToFile()) ... when the app runs with the 1st option, it works fine (excepting for a casual SEHException - that I don't know what it means), ... but when it loads the Images directly from the .jpg files, it throws a disgusting OutOfMemoryException when attempting to load Zone3Act1.jpg ... I don't know how much RAM my program needs, but my system has 2 GB, ... then I ran the game, starting on Zone3Act1, and it ran up to 4-1, where occured the same problem

I tried Image.Dispose(), Texture.Dispose(), etc, etc ..., reallocating the objects with "new" ...

Perhaps if you see the code, someone will find the bug ... there are many files, but those where the problem could be are 3 or 4, and they aren't too long

If it isn't the correct place to talk about this, I'm sorry, and please tell me where should I do
Thanks

Pablo
(Bs As Argentina)

203
General / Re: C++ SFML, Circular Movement - Help!
« on: September 21, 2013, 03:01:21 am »
I forgot to write the Distance function, i don t know why i have realized right now

// returns the distance between points P(x1, y1) and Q(x2, y2)
private int Distance(int x1, int y1, int x2, int y2)
{
    return Math.Sqrt( (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) );
}

this function is used by the one that tests the ball s bounce on the paddle

Now i ll check out about the problem with the microsoft package and the dll

if you are using VS 2012, then it s .NET 4.0 or 4.5, do i have to update that? and i guess the dll is not the same from one to another?

204
General / Re: C++ SFML, Circular Movement - Help!
« on: September 20, 2013, 10:02:07 pm »
Thank you, MiLord!
I m using Windows 7 Ultimate 32 bit ... and i have installed Visual C# 2008 Express Edition, NOT C++
i downloaded the DLL file, tried copying it to the game s folder, to C:\Windows\System32, also i ran regsvr32 at the command shell, and it says it couldn t load the MSVCP110.DLL file ...
when i tried to run the Pong, a messagebox said the DLL wasn t installed on my system, ... but it really is!

about Jycerian s pong game, i really hope that now it will work, with the circular collision and so ... actually, i am looking for solving this DLL problem, and then waiting for the binaries to see this sophisticated game

205
General / Re: Character movement & physics
« on: September 20, 2013, 09:45:46 pm »
Hello

you need that your character can gain speed gradually, and brake, and jump with parabollic effect, and fall, etc?  like Mario and Sonic?

in my poor Sonic, i already programmed that ... a little tedious ... but it s nice when you succeed

if it s this, then i can give you here the code fragments (i use C#)

Pablo

206
General / Re: C++ SFML, Circular Movement - Help!
« on: September 20, 2013, 08:58:20 pm »
Hello, Jycerian, zsbzsb, and all Ladies and Guys from SFML

let s see, first i ll try to draw the main loop and then to detail the heavy functions, that i already wrote before
if needed, please someone translate from my code to C++, thank you (i don t know why don t you all use C# ... it s easier and more legible)
i saw you were asking in the last reply for the ball s angle when it hits the border line, here it is all

while (true)
{
    PlayerInput();     // however it is, events, etc
   
    ComputerPaddleControl()    // has it been thought or programmed?
 
    DrawGraphics();    // however it is

    BallMove();          // i ll give an idea, but perhaps it s already done

    if (DetectCircunpherenceCollision( ref ballX, ref ballY ) == true)
    {
        ballAngle = AngleCircle();
    }
    else if (DetectPaddleCollision( ballX, ballY ) == true)
    {
        ballAngle = AnglePaddle()
    }

    // it would be missing the score issue, i m sorry but i insist with the goal lines, cos the ball will never be 
    // impeded to return, as you said, zsbzsb, it will bounce once and again on different points on the circle
    // lines, even if it never hits the paddles, it can t escape from the circle

    // anyway, Jycerian, you could try first if the schema and functions i wrote make the program works fine,
    // weather there are or not goal lines
}

// returns true if the ball bounces on the circunpherence
private bool DetectCircunpherenceCollision( ref int ballX, ref int ballY )
{
// already written and optimized, see last version
}

// returns true if the ball bounces on the paddle
// convert paddleAngle to radians before passing it to the Sin or Cos
private bool DetectPaddleCollision( int ballX, int ballY )
{
    int a, SideX;
   
    Paddle.Radius = paddleTexture.Width / 2;   // however it is   
    Paddle.Height = paddleTexture.Height;       // however it is

    SideX = Math.Cos (paddleAngle) * Paddle.Radius;
    for (a = Paddle.Origin.X - SideX; a<= Paddle.Origin.X + SideX; a++)
    {
        if (Distance( Ball.Origin.X, Ball.Origin.Y, a, Math.Sin(paddleAngle) * a / Math.Cos(paddleAngle) )
            < ball.Radius + Math.Cos(paddleAngle) * Paddle.Height / 2)
            return true;
    }
    return false;
}

// returns the ball s angle (in degrees) when it bounces on the circle line
private int AngleCircle()
{
    int angle, tangentAngle;
   
    // the circunpherence s tangent line at the collision point behaves as a paddle, then we get its angle and
    // then we get the new ball s angle; we add PI/2 (90 degrees) cos the tangent is normal to the radius 
    tangentAngle = (Math.Asin( (ballY - 240) / radius ) + PI / 2) * 180 / PI;   // converted to degrees

    angle = 180 - 2 * tangentAngle - ballAngle;   // here we use the same formula than when the ball
                                                                      // bounces with the paddle
    return angle;
}

// returns the ball s angle (in degrees) when it bounces on the paddle
private int AnglePaddle()
{
    int angle;
    angle = 180 - 2 * paddleAngle - ballAngle;
    return angle;
}

// makes the ball move - i don t know if already implemented
private void BallMove()
{
    Ball.Position.X += Math.Cos(ballAngle) * 5.0;   
    Ball.Position.Y -= Math.Sin(ballAngle) * 5.0;
}

I will repeat, i couldn t run this program Jycerian that sent the link, because of the MSVCP110.DLL file ... now, could any member tell me how to fix that, so i can see the game?
i don t know about DLL s nor OS s very much ... just programming
thank you

please let us know if now, the Pong works fine now
and be carefull with the variable names, if you have any doubt tell me

Pablo

207
General / Re: C++ SFML, Circular Movement - Help!
« on: September 20, 2013, 03:44:30 am »
Hello,
yeah, now i understand why the ball gets stuck ... (the collision test traps it, changing its angle indefinitely)
well, please try this, we ll make a little change
(i m assuming that now the ball, though it gets stuck, at least it does on the circle border line)

private bool DetectCircunpherenceCollision(ref int ballX, ref int ballY)
{
    int posX, posY;
    posX = ballX - 320;    // here 320 is screenWidth/2, or Xcenter

    if (posX > radius) posX = radius;
    else if (posX < -radius) posX = -radius;

    ballX = posX + 320;   // this fixes if the ball overpassed the X limit   
                                    // perhaps in C++ you d have to write *ballX = ... (indirection)
    posY = Math.Sqrt( radius * radius - posX * posX );

    // here 240 is screenHeight/2 or yCenter
    // the assignments prevents the ball to overpass the Y limit at the collision point
    if (ballY <= 240 - posY) { ballY = 240 - posY; return true; }
    else if (bally >= 240 + posY) { ballY = 240 + posY; return true; }
   
    return false;
}

now the function prevents the ball overpasses the border line, then i supose it shouldn t get stuck any more
Note you must pass to the function the X and Y values of the ball BY REFERENCE (or the address), in order it can change their values in the very probable case that they overpass the circle line (it occurs because the pixels you add to the ball trajectory may not match just on the circle line, but a little before or after)

then, your main loop could include:

.........
// here increase the ball x, y ... that is, it moves
for example:
ballX += cos (ballAngle) * 5.0;
ballY += sin (ballAngle) * 5.0;    suposing it runs 5 px per frame

if (DetectCircunpherenceCollision(ref ballX, ref ballY) == true)     // don t know if in C++ you use & not ref
{                                                                                             // and *var = ... to access the value
    ballAngle = AngleCirc();      // the new ball angle when it bounces on the circle line
}                                           // i wrote this function before, i don t remember how i called it
........

Let me know if it works now

And, i tried to run this program, and i couldn t, appears a letter that says the file MSVCP110.DLL is not in my system ... i downloaded the DLL file, copied it to C:\Windows\System32, reboot my PC, and it still says the DLL is not in my system, so i cant run the Pong.exe ...

Can someone help me with this?



208
General / Re: C++ SFML, Circular Movement - Help!
« on: September 19, 2013, 06:06:01 pm »
320, 240 are the coordinates of the center of the screen, and of the circle

what i was trying is to give to Jycerian a function to detect when the ball bounces on the circunpherence, he is developing a pong game where the paddles are inside a circle ...  8)

we could write, instead of 320, screenWidth/2, and instead of 240, screenHeight/2 ... technically, you are right, again, but i don t usually do this, cos i m lazy

feel free to read all the thread, it s very interesting ...
i hope the binaries are ready soon, so we can play ...

but .... I ask again, Jycerian, shouldn t there be goal lines?

209
General / Re: C++ SFML, Circular Movement - Help!
« on: September 19, 2013, 05:25:31 pm »
you are very right, MiLord / MiLady

then we could do something like this:

private bool DetectCircunpherenceCollision(int ballX, int ballY)
{
    int posY, posX;
    posX = ballX - 320;
   
    if (posX > radius) posX = radius;           
    else if (posX < -radius) posX = -radius;
   
    posY = Math.Sqrt( radius * radius - posX * posX );    // now the arg >= 0

    if (ballY <= 240 - posY || bally >= 240 + posY) return true;
    return false;
}

I really thank you for the detail, cos the ball could overpass the circle line, that is, it won t land exactly at the border line ... i supose now it s fixed 


210
General / Re: C++ SFML, Circular Movement - Help!
« on: September 19, 2013, 04:33:24 pm »
I understand that by "circular collision" you mean that the ball bounces on the circunpherence
try this:  (applying the Pithagoras Theorem)

private bool DetectCircunpherenceCollision(int ballX, int ballY)
{
    int posY, posX;
    posX = ballX - 320;
    posY = Math.Sqrt( radius * radius -  posX * posX );

    if (ballY >= 240 + posY || ballY <= 240 - posY) return true;
    return false;
}

you can use this function on every loop, if it returns true, then you would have to get the new ballAngle ; the circunpherence X, Y to get the new angle will be the same than the ball,

the args to be passed should be the x, y of the ball center or origin, to get more precission
Also the function could be optimized and more exact, using the ball radius to detect when it just touch the circle line with its first point, but it would be too much difficult ... and unnecesary ... at least by now

i was forgetting, ... the ball scroll:  (let s supose it runs 5.0 px every loop)

ball.Position = new Vector2f( ball.Position.X + cos(ballAngle) * 5.0, ball.Postion.Y + sin(ballAngle) * 5.0 );

you don t have to worry for the sign of the ball scroll, depending on the angle it changes automatically

We would need -i think- a lady or a guy from SFML forum, that translates for you the code i wrote here to C++ ... i m sorry, i just use C#

let me know if this works, and if you need anything else
and if you get the game better, please update the link or repost it so we can see

Pablo


Pages: 1 ... 12 13 [14] 15
anything