### 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 - Father_Sloth

Pages: [1] 2 3 4
1
##### General / I need help with this game i am trying to make.
« on: May 09, 2011, 07:49:01 pm »
Well I tried implementing your method actually :wink: but I think I've screwed up somewhere as my angle always goes towards the bottom left corner, which results in the opponent gaining a point Heres the code anyway:

Collision:
Code: [Select]
`bool Collision (const sf::Sprite& a, const sf::Sprite& b){ int aX = a.GetPosition().x; int bX = b.GetPosition().x; int aY = a.GetPosition().y; int bY = b.GetPosition().y; int aW = a.GetSize().x; int bW = b.GetSize().x; int aH = a.GetSize().y; int bH = b.GetSize().y; if ((aX < (bX + bW)) && (aX + aW) > bX && (aY < (bY + bH)) && ((aY + aH) > bY)) { return true; } return false; }`

The bounce:
Code: [Select]
` // Check collision between Bat and ball if (Collision(PlayerBat, Ball)) { Ball.Move(cos((ballAngle/180)*PI) * ballSpeed, sin((ballAngle/180)*PI) * ballSpeed);  // Move the ball }`

- Simon

2
##### Graphics / Somtimes Black Line appears when drawing a sprite
« on: May 09, 2011, 06:49:47 pm »
Does this happen when moving, when not or what? If it's only when moving you could try limiting the Framerate or such.

- Simon

3
##### General / I need help with this game i am trying to make.
« on: May 08, 2011, 11:29:40 pm »
Can I ask how you would do collision with the bat if it is drawn from the centre?

Also whenever I use your method for bouncing the ball off the bat it always goes towards the bottom left corner, what am I doing wrong?

- Simon

4
##### General / Delay using Clock
« on: May 08, 2011, 11:08:26 pm »
Ahh thanks, just tried put that in thanks. It's fixed the whole increment problem and I've also finally fixed the background one but for some reason my thing still says "EXC_BAD_ACCESS" which leads me to believe that i'm screwing up with like a memory leak due to it showing me the faulty memory address.

So what's happening in my code is that i'm creating a vector of sprites and for every 3 seconds i want to execute the code you've already seen. Then after that I want to move the vector along the x axis using a for loop and incrementing the x co ordiantes. Now I know this may come off as being lazy, but really I just want to get the bug fixed. so heres the code involving the vector and maybe somebody can point out where i'm going wrong:

Code: [Select]
` // Set up rings vector vector <sf::Sprite> ringVec; vector <sf::Sprite>::iterator spawnIterator = ringVec.begin(); vector <sf::Sprite>::iterator ringIterator = ringVec.begin();`

Then theres the one you've seen before. Then this:

Code: [Select]
` // Check ring collision for (ringIterator = ringVec.begin(); ringIterator < ringVec.end(); ringIterator++) { float ringPos = ringIterator->GetPosition().x; if ( (WaterMelon.GetPosition().x < ringPos + (UPPER_RBOUND - 20)) && (WaterMelon.GetPosition().x > ringPos + (LOWER_RBOUND + 20)) ) { // Add to score if melon passes through ring score += RING_POINTS; } else if ( (ringPos + RING_Y) > WaterMelon.GetPosition().x > ringPos + (RING_Y - 20) || (ringPos - RING_Y) < WaterMelon.GetPosition().x < ringPos - (RING_Y + 20) ) { } } // Move Rings for (ringIterator = ringVec.begin(); ringIterator < ringVec.end(); ringIterator++) { Move(-moveSpeed, 0.f, *ringIterator); } // Check if rings out of bounds for (ringIterator = ringVec.begin(); ringIterator < ringVec.end(); ringIterator++) { float ringPos = ringIterator->GetPosition().x; if (ringPos < 0 - (RING_Y / 2)) { ringVec.erase(ringIterator); } }`

Then finally to draw:
Code: [Select]
` // Draw all Rings for (ringIterator = ringVec.begin(); ringIterator != ringVec.end(); ringIterator++) { App.Draw(*ringIterator); } `

Thanks a lot guys.

- Simon

5
##### General / Delay using Clock
« on: May 08, 2011, 09:03:41 pm »
I'm not. I call reset in main() once and then whilst the app is running (the scond part of code) I reset it after each time a ring is spawned

6
##### General / Delay using Clock
« on: May 08, 2011, 08:20:10 pm »
Hey everybody

Ok so now I've got three problems:

1) My background is still shifted. I changed the color when app calls clear() and It's actually showing me that part of the screen is not covered. Yet none of those numbers have changed.

2) I had to change the code that tntexplosivesltd gave me and now when I send it to cout it increments by 0.000000001 not by 1 second as the sfml tutorials say?

3) As soon as my time variable gets to the set delay time and the spawn code executes the program crashes and comes up with an error I've never seen before. Also when the program crashes I have to kill it through the compiler which I NEVER have to do, so my only guess is I'm doing something highly illegal? Heres the code:

Code: [Select]
` // Initialise counter for ring spawn delay sf::Clock Clock; float time = 0; float ElapsedTime = Clock.GetElapsedTime(); Clock.Reset(); `

and

Code: [Select]
` // Spawn Rings time += ElapsedTime; if (time >= DELAY_TIME) { // Add ring sprite to the ringSpawn vector ringVec.push_back(Ring); // Give that ring a random y co ordiante spawnIterator->SetX(0); spawnIterator->SetY(rand_Y); // Increment iterator spawnIterator++; // Reset the clock Clock.Reset(); }`

Also to see the crash screenshot heres the Link - I know laurent hates when I post big screenshots on here

- Simon

p.s. reaaally sorry bou the multiple posts. I guess that's my first reaction after I get scared  :shock:

7
##### General / Delay using Clock
« on: May 08, 2011, 07:30:26 pm »
Ok so I got the whole set up working alright but I've still got the background problem for bo reason. It was working fine until I f***ed it up a couple of debug's ago...

8
##### General / Delay using Clock
« on: May 08, 2011, 07:11:46 pm »
I just tried placing that code above the spawn part and now I've got some crazy error. At first my compiler went crazy when I tried using the arrow keys to move like normal, and now after removing the code my background is offset by a couple pixels despite being set at (0, 0).

Curse you tntexplosivesltd!!!

- Simon

9
##### General / Delay using Clock
« on: May 08, 2011, 07:02:58 pm »
I thought clock self increments as time goes on after the last reset? I did not know I had to manually increment it myself :/

Just out of interest where abouts do you suggest I increment it in my code?

10
##### General / Delay using Clock
« on: May 08, 2011, 12:38:42 pm »
Thanks for that laurent. I think maybe the problem is somewhere else as I just adjusted the code and to my surprise still no success. I sent my time to cout and i got the figure
Code: [Select]
`9.53674e-07`

Any reason why that might be?

11
##### General / Delay using Clock
« on: May 08, 2011, 11:49:23 am »
Hey everybody

I've finished my game (almost) and I have one obstacle left. Now if i can fix this everything will work as it is the key to my spawn engine. The goal is to add a ring sprite to the vector every time the clock reaches the delay time constant.

First part at the top of main():
Code: [Select]
` // Initialise counter for ring spawn delay sf::Clock Clock; float Time = Clock.GetElapsedTime(); Clock.Reset();`

Second part whilst App is running and player alive:
Code: [Select]
` // Spawn Rings if (Time == DELAY_TIME) { // Add ring sprite to the ringSpawn vector ringVec.push_back(Ring); // Give that ring a random y co ordiante spawnIterator->SetX(0); spawnIterator->SetY(rand_Y); // Increment iterator spawnIterator++; // Reset the clock Clock.Reset(); }`

Can you see what's going wrong? Xcode produces no errors and I've followed everything in the tutorial.

12
##### Graphics / White line in Sprite..
« on: May 08, 2011, 11:16:37 am »
Thank you so much! That really helped, I just set my two moving images smooth to false and now all artefacts are pretty much gone (I say pretty much because there is still some lines but there not white and they happen less).

Do think it might of had something to do with the speed of movement?

- Simon

13
##### Graphics / White line in Sprite..
« on: May 05, 2011, 09:15:16 pm »
Of what exactly? The part where i create the sprite/images or the part when i draw them?

- Simon

p.s. sorry for the late response my internet went down

14
##### Graphics / White line in Sprite..
« on: May 03, 2011, 07:00:19 pm »
Hey guys

Okay so I've recently started up again with sfml and have recently been noticing a slight glitch in my sprites..

So I've got a *really* simple game, in which the player moves around a melon. That's it. I've been using different file formats for the sprite, I've even been limiting my FPS and experimenting with that but still, remaining unsuccessful, have been getting a white line moving up the sprite. I tried taking a screenshot but it happens so fast and only now and again every 30 seconds.

Please can you show me where I might be going wrong

- Simon

15
##### Network / Mac & Windows playing together?
« on: April 15, 2011, 11:44:35 am »
Hey Everybody

Been a while since I last posted but I'm now working on a top down shooter for me and my friends. Now I have been reading into using sfml's network capabilities and was wondering can me and my friends play together as I'm on a mac and their on windows.

Is there anyway I can do this or is it just not possible?

Thanks Guys

- Simon

Pages: [1] 2 3 4
anything