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 - stuart88

Pages: [1]
1
Feature requests / Re: Making SFML work with web assembly?
« on: July 06, 2018, 03:33:34 pm »
Bumping this thread as I'd also like to know if there's much info on turning SFML projects in wasm files.

Cheers!

2
DotNet / Re: Event handling C# (single keypress inputs)
« on: September 26, 2017, 09:11:40 am »
Never mind, figured it out  :D

A bit of deeper searching gave me this:

window.KeyPressed += OnKeyPressed

void OnKeyPressed(object sender, SFML.Window.KeyEventArgs e)
            {
                if (e.Code == Keyboard.Key.A)
                {
                    // DO STUFF
                }
            }

All inside this part:
static void Main()
{
      // CODE HERE
}
Works a treat.

 :D

3
DotNet / Event handling C# (single keypress inputs)
« on: September 26, 2017, 08:42:45 am »
I can't get my head around how to deal with single keypress inputs using the .NET (C#) version of SFML.

I previously used the C++ version and was fine with the
window.pollEvent()
method, but I can't do that with .NET, or at least I can't figure out how to do it.

Could someone write a quick thing to demonstrate how I would read a single keyboard input and make it do something?

Many thanks.

4
Audio / Re: Added sound to program, now just getting white screen.
« on: February 26, 2017, 05:56:06 pm »
I have absolutely no idea what I did, but the problem seems to have righted itself!

Code is still in the same spot of the script and I didn't make any wild changed to it, yet now everything runs fine, with sound.

Probably a typo somewhere.

Thanks, and apologies for making this waste of a thread  :-[

5
Audio / Added sound to program, now just getting white screen.
« on: February 26, 2017, 05:04:07 pm »
So my programs works fine, and now I'm just upgrading it by toying with sound for the first time. However, what appears to be quite a simple attempt at importing and using a sound file is resulting in the program opening to a white screen.

Does anyone know what could be causing this?

The tiny amount of sound-related code I'm using is below:

        sf::Music wind1;
        wind1.openFromFile("ambient-loop2.wav");
        wind1.setLoop(true);
        int vol = 50;
        wind1.setVolume(vol);
        wind1.play();

This code is inside int main, but not inside the main game loop. I think I may be going wrong with that aspect - I'm not sure where I'm supposed to create the Music and then tell it to play.

As an aside, my aim is to make it so that the volume changes in unison with another parameter in the project - getting louder or quieter as the parameter value changes. It's currently setup to update the volume just before all the calls to draw all the new sprites at the end of each loop.

However, the program doesn't get any further than a white screen now anyway.

Hints appreciated, thanks.

6
SFML projects / Second project complete - 2D fluid flow simulator
« on: February 02, 2017, 10:44:34 pm »
Quite pleased with this one - https://github.com/Stuart88/Flow-sim/blob/master/Flow%20Sim.rar

As with my previous creation, it isn't actually game, it's a simulator for those with an interest in physics or engineering.

This one models fluid in an open chamber with basic flows, with interactivity enabled for changing flow speed, rotation speed and other things.

Code (on GitHub) is a bit messy again but that's all part of the learning process I guess. First go at using vertex arrays and I had to jump in at the deep end with classes too.

Enjoy  :D - https://github.com/Stuart88/Flow-sim/blob/master/Flow%20Sim.rar


7
Window / Re: "Key Pressed" event without pressing a key?
« on: February 02, 2017, 04:35:09 pm »
Hmm kind of.

On second thought, I think the problem is my own fault. I wrote a ton of code directly for each keypress, rather than directing them to functions elsewhere.

The 6 P's strike again, heh.


8
Window / "Key Pressed" event without pressing a key?
« on: February 02, 2017, 03:19:03 pm »
I have two cases where I want something to happen which is equivalent to a key press, without that key being pressed.

In the case of the code I've written, I'd like to make it so that pressing 'Space' runs the same code as pressing 'R'.

Secondly, I have a problem wherein I'd like to initiate the equivalent of a key press after a certain amount of time has elapsed. Something like:

if(elapsedtime % 5 != 0)
{
Tell the program to run the code where the "S" key was pressed
}

I know I could just copy and paste the code blocks into the area they're needed, but I still wonder if there's another way to do this. Having two huge chunks of the same code feels a bit messy.

Many thanks.

9
Ok I've just had a read of the stuff on vertex arrays. More fascinating stuff, cheers :)

10
Cheers for the replies. That stuff about instancing (and openGL in general) is new territory for me but I'll definitely have a look. I did wonder how games with many thousands of entities manage to deal with such information.

The smoke simulator looked extremely awesome too. Definitely helped a ton with getting my head around the best way to do it. The bottom part of the article about velocity fields was fascinating (and obvious actually as it's a basic premise of most vector calculus in physics - I definitely should have known that  ::) ! )

I'll provide an update whenever the next little physics sim is made. Might just try the smoke/fluid sim next. :)

11
Hi all

I couldn't find an 'intros/newbies' area here so figured I'd dive in here with my first post!

I'm a student of physics and recently got into the idea of putting basic (or complex) physics principles into my own simulators.

So to start I've just thrown together a little attempt at simulating particles in a box. It consists of a larger red (player) ball which you can move around to collide with other particles in the box. Manipulable settings include player mass, particle mass, gravity strength, number of particles, 'anti-gravity' player ball, 'freeze' the particles, and - my favourite - turn on electric fields around all the particles so they repel each other.

There's no 'gaming' element to it, but I'm pleased nonetheless as I've seen that it's possible to quite easily put physics into games. My next effort will probably be something relating to quantum mechanics or fluid dynamics. I'm in the process of learning geophysical fluid dynamics now too so in future I hope to do some basic planetary simulations (in 3D?), where the user can do things like set the rotation speed, gravity, density of atmosphere, generate clouds or ocean currents etc. Along the way I might have a go at making some games out of these things too.

Anyway, here's my first little project  :) - https://github.com/Stuart88/Particles

Full executable is available in the RAR archive on GitHub, or alternatively the source code is there along with the necessary font and sprite files

(click to show/hide)


Pages: [1]