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

Pages: 1 2 [3] 4 5
31
##### General / Re: Smart Moving Problem
« on: May 07, 2017, 10:39:25 am »
So.. im still not 100% sure what part you want..
So, this is a compleate (if a bit hacky) way to rotate, accelerate, and move a space ship (m_Ship)
In my example I just use a ractangeShape for the ship, but you can use a sprite just fine.
you will need the values.

float m_xVel = 0, m_yVel = 0, m_accel = 0.01;
hidden somewhere where MoveShip can accec them.
the x and y Val is the current speed that the ship is moving at the x and y axis.
the m_accel is how fast it accelerates in a given direction.

in addition you will need a sf::Keyboard m_Key
This can be done differently, but for this short code that is all i made.

float m_xVel = 0, m_yVel = 0, m_accel = 0.001;
sf::Keyboard m_Key;

//In the class//
void Game::MoveShip() {
//Rotate right and left
if (m_Key.isKeyPressed(sf::Keyboard().Right)) {
m_Ship.setRotation(m_Ship.getRotation() + 1);
}
if (m_Key.isKeyPressed(sf::Keyboard().Left)) {
m_Ship.setRotation(m_Ship.getRotation() - 1);
}
//Accelerate the ship forward.
if (m_Key.isKeyPressed(sf::Keyboard().Up)) {
m_xVel += (cos(m_Ship.getRotation() / 180 * 3.1415)) * m_accel;
m_yVel += (sin(m_Ship.getRotation() / 180 * 3.1415)) * m_accel;
}

//Make the actual movement of the ship.
m_Ship.setPosition(m_Ship.getPosition().x + m_xVel, m_Ship.getPosition().y + m_yVel);
}

this code will rotate the ship and move it around using the Up, Right and Left button.
the first two If statements simply looks for pressing the Right and Left key. and apply rotation to the ship accordingly.
the third, as the first two looks for a key press, but this time the up key.
if the up key is pressed, it grasp the current rotation, and using cos and sin, it calculates how much to add to the ships x and y speed (velocity).

note that the ships rotation is divided by 180*PI, the reason for this is that SFML rotation uses 360 degree rotation, where the math con and sin is geard towards radiant (rotation = 0-1)

In this case, a rotation of 0 or 360 is horizontal fazing right.

This will give you movement like in the asteroids games where your ship will float around in whatever direction until it is accelerated in another direction.

i Hope that helps.

if you want the full code to look over, i can upload that somewhere.

32
##### SFML projects / Re: Little Scout [LD#38 Jam]
« on: May 07, 2017, 09:29:26 am »
No problem.

Nope? When I got outside I hit the slope and from there just fell of the right side og "the world"
Fell for about 30 seconds,then quit by hitting the red X button.
Tried three times, never got any endings...

33
##### SFML projects / Re: Little Scout [LD#38 Jam]
« on: May 07, 2017, 12:30:41 am »
I took a look at it.
Really interesting mechanic.
I'm not 100% sure, but is the world meant to "end" when you get outside (after the trampoline)

But the graphics and overall mood is great, there are some bugs, but i see others have mentioned them in the comments. all in all, a good shoot in that short amount of time

34
##### General discussions / Re: Artificial Intelligence.
« on: May 06, 2017, 10:50:13 pm »
Hey, I agree fully with Elias.
The book suggested is a great entry point...

One thing that could be important is to figure what kind of Ai you want... How important is "natural" dessisions?
On one end you could just use a state machine. (see enemy? Yes -> attack, no -> next question!)
On the other end you could run a small neural network (or an advanced one)

But some questions...
What are your knowledge of programming?
Any ai knowledge?
Have you made other games or game parts before?
Is this a top down or side view tank game?

And much more...
Best regards.

35
##### SFML game jam / Re: More?
« on: May 06, 2017, 09:09:45 pm »
So...
I love jams... But I've only had the time for a few...
That said, I think jams are a great way to generate interest in SFML.
Let me explain..
If we may a trice or twice yearly game jam,
Just like any other jam, but with SFML as a requirement.
I think it would generate some interest. But not much... Let's be honest, there are a lot of jams out there, and one thing a lot of people love about them is the freedom they offer.
So limiting to SFML could be a problem..
How do we fix this?
Prizes.. 90% of all the jams offer no price aside from the glory....

I think prizes, in the form of SFML books(or c++/game programming books I'm gemmeral) I'm talking printed books, not ebooks... Don't get me wrong, I buy all my books as ebooks, but having a print does have its bennifits, and would feel more like a real prize... And if it's SFML books, would further spreed the love...

If anyone (especially the good people behind SFML) thinks this is a good idea, I'd even be willing to sponsor a book purchase for the first jam... (Any of the current SFML books)

I think that could be good... But what do you guys think?

36
##### General discussions / Books list and suggestions.
« on: May 06, 2017, 08:51:27 pm »
It's a long time no see.

So, I've just revised a bunch of books.
Some on programming in general, some on c++, and lastly some specific on SFML.

I'd like to hear if anyone has any suggestions as what to add to my collection (or want to hear a personal opinion on any of my books)
I like to program simulations and simple small 2d games.
(love boids, cellular automatons, neural networks and any thing that mimics natural systems...)

My library so far consists of:

-SFML game development by example
-SFML blue prints
-SFML essentials
-Mastering SFML game development (got it today)
-Procedural Content Generation for C++ Game Development
-Game programming patterns
-Beginning C++ Through Game Programming
-Programming Game AI By Example
-Artificial Intelligence for Humans, Volume 1: Fundamental Algorithms
-Artificial Intelligence for Humans, Volume 2: Nature-Inspired Algorithms
-Artificial Intelligence for Humans, Volume 3: Deep Learning and Neural Networks
(also got those 3 today)

Older books:
-Beginning Java Game Programming
-Developing Games in Java

So.. What do you guys think... Anything to add? What do you guys have?

37
##### General discussions / Re: Mastering SFML Game Development (n-th SFML book?)
« on: May 06, 2017, 08:31:41 pm »
I just got the book today.
I'm looking forward to go through it...

All in all I'm glad, my c++ library is growing well

38
##### SFML projects / Re: Racod's lair - a coop dungeon crawler [Demo Release]
« on: July 29, 2016, 09:24:51 am »
I've tried it to, and will come with full review later. But about the full screen:
Have 2 extra floats:
Xscale, Yscale.
Make sure to store your original oXsize and oYsize.
And have your current cXsize and cYsize.

Then after each resize:
Xscale = (1.0 / oXsize)*cXsize.
Yscale = (1.0 / oYsize)*cYsize.
If (Xscale < Yscale) your_scale_function(SF::vector2f(Xscale,Xscale));
Else your_scale_function(SF::vector2f(Yscale,Yscale));

This way the scale /shown window will always be the shortest.

Another more hacky way would be to draw a black texture with a transparent center the size of your view. Then render that last over ever, scaled to the view...

Just suggestions....

39
##### SFML projects / Re: First real game project - task: attacking/deal damage
« on: July 28, 2016, 09:30:55 pm »
Okay, description for post above this one:

I've done a lot so far, and for the next time ill simply do rearrangement and clean up of the code, not adding anything before it is done. but here is what I've done so far.

//the level handler can read monsters into the level
-each monster is represented by a color of 255,0,X where X corresponds to a ,monster type.

//zombies now do damage

//playing characters now do damage

//playing characters can die,
-when they do you cannot re select that character
-the engine skips updates for death characters
-if all 3 characters dies, the level starts over.

//zombies can die
-the engine skips updates for death zombies.

//cooperation
- if the active player character stands close to another player character and jumps, said character will give a boost to jumpPower.

//manual reset
-going out to the main menu from the pause screen will result in level reset!

//more animations
--climb up/slide down stairs
--give a lift! (for cooperation getting over obstacles)
--Multiple attack animation possibilities

40
##### General / Re: Searching a good open source project to learn sfml
« on: July 28, 2016, 12:39:53 pm »
You are most welcome, don't forget to keep us updated on your progress and to inform us if you need any help

41
##### SFML projects / Re: First real game project - task: attacking/deal damage
« on: July 28, 2016, 04:37:49 am »
another update.. I'll write the details tomorrow.. night night for now!!!

http://youtu.be/B-mRCY-JCYQ

42
##### Window / Re: program slows down during fullscreen
« on: July 28, 2016, 12:00:28 am »
A sorry.
a writing mistake...

The line "targetTime = 0;" is called upon initialization. so only once.

Thus the game will catch up. Eg:
(click to show/hide)

This is why i use a flexible time step, this way you avoid delta time and you avoid updating out of sync (mostly) the downside is that you must update target time each time you pause/pause, to avoid (clock() is 10000 target time is 16 = to many repetitions)

But no, this is not the error i'm experiencing, since animate() and the game functions are both called within the same main loop, they should update 1 time each right after each other, but for some reason the game function seems to be called multiple times :S

43
##### Window / Re: program slows down during fullscreen
« on: July 27, 2016, 08:35:11 pm »
The framerate is a flexible fixed timestep. animate is called each time the game loop is called.

:

targetTime = 0;
if(clock() > targetTime) {
targetTime += (1000/targetUPS);
doGameLoop();
animate();
}

*target time is an int
*targetUPS = target updates per second.

so if the character moves, his animation should update.

rendering is done sepperatly.

my targetUPS is normaly set to 60, so an update should happen no more than once per 0.016 seconds.
a normal update including animate() takes 0.003 to 0.008 seconds, so there is time to spare...

44
##### Window / program slows down during fullscreen
« on: July 27, 2016, 06:20:52 pm »
So, I have this game that im currently working on
(click to show/hide)

the normal screen size for this game is 800 by 600.
it uses sf::view (400 by 300 pixels) and sf::window
it uses a flexible timestep
it runs fine using only 3-6& cpu and few %memory

but if i toggle fullscreen to true (or if i start in full screen) it slows down a lot.
but also, the animation gets slower still and thus out of sync.
(eg, walking becomes sliding)

toggeling fullscreen back off again solves the problem instantly...
I've tried running as administrator and searching with all my google'fu but no solution so far.

the toggleFullscreen code is:

void Window::ToggleFullScreen() {
m_isFullscreen = !m_isFullscreen;
Destroy();
Create();
}

if it has any interest the animation code is called right after the units have updated their current location and status.

void Agent::animate() {
_currentFrame+= (_speed / 160);
if (_aniAtt) {
if (_currentFrame > _attFrames) _currentFrame = 0;
_animation = 3;
}
else if (_aniJump) {
if (_yVel < 0) _currentFrame = 0;
else _currentFrame = 1;
_animation = 2;
}
else if (_aniWalk) {
if (_currentFrame > _walkFrames) _currentFrame = 0;
_animation = 1;
}
//standing
else{
if (_currentFrame > _standFrames) _currentFrame = 0;
_animation = 0;
}
if (_dirLeft) _animation += 6;
}

_animation corresponds to a specific row and _current frame to the column in a texture.
a sprite is set to the corresponding coordinates and then rendered to the window.
_speed is the movement speed of the characters.

again, the cpu, memory and gpu usage remains roughly the same, and never exceeds 12% but both the program in general slows down and the animation, the animation just more than the rest.

any suggestions?

45
##### General / Re: Unresolved external symbol when statically linking but works fine when dynamic
« on: July 27, 2016, 04:22:18 pm »
have you added the -s & -s-d lib files to:

C:\Users\NAME\Documents\Visual Studio 2015\Projects\ConsoleApplication2\ConsoleApplication2
I know some turoeials only tell you to add the standard lib files.

Pages: 1 2 [3] 4 5