[QUOTE=Swog;45048542]If I get a boolean statement true in a for loop, how do I make it skip that run necessarily in Java?
For example, run 1, 2, 3, and 4:
Run 1: A boolean statement was returned false
Run 2: A boolean statement was returned true mid-run, end run and go to next
Run 3: A boolean statement was returned false
Run 4: A boolean statement was returned true mid-run, end run and go to next
You get an idea. Should I just mark a boolean true and check it before I carry out the operations inside the run, and if it's true, just make an empty block of code, and place operations in the else block something like this?
Or is it impossible?[/QUOTE]
Are you looking for "continue"?[cpp]for (...) {
// Do stuff
if (statement())
continue;
// Do stuff
}[/cpp]
[QUOTE=Dienes;45048039]Challenge accepted.[cpp]// Load a texture
sf::Texture tex;
tex.loadFromFile("img.png");
// Make a sprite out of it, move and rotate it
sf::Sprite spr{tex};
spr.move(100.0f, 200.0f);
spr.rotate(90.0f);
// Make a camera and zoom in
sf::View cam;
cam.zoom(0.5f);
// Make a window and draw the sprite using the camera
sf::RenderWindow wnd;
wnd.setView(cam);
wnd.draw(spr);[/cpp]
This is SFML. It doesn't get any more OOP and simple than that IMO.[/QUOTE]
Wow. I wonder what the hell I was doing with SFML, back when I tried it out a year or so ago.
That is more or less [b]exactly[/b] what I wanted.
Now if only it wasn't C++, but fuck, beggars can't be choosers. Gives me motivation to get back into the swing of C++, if nothing else.
Thanks a lot, Asgard and Dienes. I'll definitely look into playing around with SFML, get the hang of things.
[QUOTE=Gmod4ever;45049525]Wow. I wonder what the hell I was doing with SFML, back when I tried it out a year or so ago.
That is more or less [b]exactly[/b] what I wanted.
Now if only it wasn't C++, but fuck, beggars can't be choosers. Gives me motivation to get back into the swing of C++, if nothing else.
Thanks a lot, Asgard and Dienes. I'll definitely look into playing around with SFML, get the hang of things.[/QUOTE]
[URL="http://sfml-dev.org/download/bindings.php"]Pick your poison.[/URL]
[QUOTE=Dienes;45049581][URL="http://sfml-dev.org/download/bindings.php"]Pick your poison.[/URL][/QUOTE]
God damn man, if you keep being this awesome, I'm going to have to pull out my alt so I can double-Winner you. :v:
[QUOTE=Dienes;45049581][URL="http://sfml-dev.org/download/bindings.php"]Pick your poison.[/URL][/QUOTE]
[QUOTE]CSFML
Status active
Language C[/QUOTE]
Who???
[QUOTE=ECrownofFire;45039453]1. Stop using raw pointers in C++.
2. There is no way to avoid using a loop here. And besides that, the memory allocation is going to [B]by far[/B] be the most expensive part of it.[/QUOTE]
I'm with you if you're talking about ownership semantics, and that you should practically never use new or delete in C++. But what if I want to make a vector of reference-like things to objects, while the vector should not really own the objects? What should I use then rather than storing raw pointers?
[QUOTE=ArgvCompany;45058460]I'm with you if you're talking about ownership semantics, and that you should practically never use new or delete in C++. But what if I want to make a vector of reference-like things to objects, while the vector should not really own the objects? What should I use then rather than storing raw pointers?[/QUOTE]
That's what I use raw pointers for also.
[QUOTE=ArgvCompany;45058460]I'm with you if you're talking about ownership semantics, and that you should practically never use new or delete in C++. But what if I want to make a vector of reference-like things to objects, while the vector should not really own the objects? What should I use then rather than storing raw pointers?[/QUOTE]
Basically, you use unique_ptr for sole ownership, shared_ptr for shared ownership, weak_ptr for temporary ownership and check-before-use, reference_wrapper for non-ownership. If reference_wrapper fails (for example because it cannot be null) then use a raw pointer. It's not that raw pointers are completely obsolete or banned now.
Has anyone worked with X.509 certs, PKCS#7, implementing PC/SC for some smart card, or raw communication with smart cards (using standardized APDUs)?
If you know something useful about those technologies, we might pay for consultation. Or if you have code you can sell with a permissive license, even better.
[QUOTE=Dienes;45058508]Basically, you use unique_ptr for sole ownership, shared_ptr for shared ownership, weak_ptr for temporary ownership and check-before-use, reference_wrapper for non-ownership. If reference_wrapper fails (for example because it cannot be null) then use a raw pointer. It's not that raw pointers are completely obsolete or banned now.[/QUOTE]
Didn't know about reference_wrapper, thanks.
[QUOTE=Dienes;45058508]Basically, you use unique_ptr for sole ownership, shared_ptr for shared ownership, weak_ptr for temporary ownership and check-before-use, reference_wrapper for non-ownership. If reference_wrapper fails (for example because it cannot be null) then use a raw pointer. It's not that raw pointers are completely obsolete or banned now.[/QUOTE]
I'm pretty rusty with C++ at this point, but if I understand you correct, shared_ptr behaves like references in Java and C# and the likes, correct?
In what situation would I need to use unique_ptr rather than just storing the instance itself? And what benefits does std::reference_wrapper provide over raw pointers?
[QUOTE=ArgvCompany;45058749]I'm pretty rusty with C++ at this point, but if I understand you correct, shared_ptr behaves like references in Java and C# and the likes, correct?[/QUOTE]
Yes. Whenever you create one shared_ptr instance from another (via copying), the reference-counting kicks in. But shared_ptr is not intrusive, i.e. when you create two independent instances from the same raw source, you get in trouble.
[QUOTE=ArgvCompany;45058749]In what situation would I need to use unique_ptr rather than just storing the instance itself?[/QUOTE]
When storing the instances themselves you might run into performance issues for things like sorting, reallocating, etc. Plus, having a unique_ptr in the container allows you to move it out and transfer the ownership somewhere else without touching the instance itself.
[QUOTE=ArgvCompany;45058749]And what benefits does std::reference_wrapper provide over raw pointers?[/QUOTE]
Due to the history of C, the ownership of a raw pointer is not clear. Sometimes you silently receive ownership together with a pointer, sometimes you don't. C++ introduced references, which not only simplify the usage syntactics of "pointers", but also imply non-ownership. So ideally, you would want to store a reference in a container to signal the semantics of "I know of the target, but I don't own it". Problem is, that vector<T&> etc. does not work. So now they added reference_wrapper, which is meant to be a copyable reference type for you to use in such cases. Like native references, they cannot be uninitialized (referencing nothing), so that's the only drawback (or advantage) compared to pointers. So using them instead of pointers is rather about expressiveness and semantics than actual technical benefits.
This may be more web developement material, but i figured id ask here as well.
How do you manage user interaction to your website/webapp via email?
What I mean is like how facebook allows/used to allow users to email a user specific email adress to ,for example, update their status.
I want to have a webservice that can generate a unique email address, or maybe just have one email address and then just check who sent the email against the registered users to sort them, in order to allow users to submit data to a web application
Anyone had this error before in visual studio 2013? It randomly pops up now and then when opening files (which it then failes to open) like xml files and such. Also when i make a new visual studio extensibility project, this one pops up (and fails the project creation)
[img]http://i.imgur.com/GfrBPeu.png[/img]
VS repair didn't do anyhing except wasting time. Disabeling all extensions didn't do anything either.
EDIT: Fixed it. I think it happend because i had installed the update 2 preview AND release. Uninstalling removing and reinstalling update 2 fixed it it seems
[QUOTE=Richy19;45062059]This may be more web developement material, but i figured id ask here as well.
How do you manage user interaction to your website/webapp via email?
What I mean is like how facebook allows/used to allow users to email a user specific email adress to ,for example, update their status.
I want to have a webservice that can generate a unique email address, or maybe just have one email address and then just check who sent the email against the registered users to sort them, in order to allow users to submit data to a web application[/QUOTE]
Sounds like you need an SMTP server, it's not [I]too[/I] complicated.
Don't bother with IMAP, the protocol is so nasty that there's not a since free .NET library.
POP3 is unsafe and can lose message if there's a connection issue. With SMTP the user will at least get an error message back.
Have fun parsing mails though, it's comprised of some of the most awful standards you'll find on the Internet.
[QUOTE=Tamschi;45065855]Have fun parsing mails though, it's comprised of some of the most awful standards you'll find on the Internet.[/QUOTE]
...Until you get to editable PDFs.
So I'm just dinking about with SFML in C#, just to get used to it, and...
How do I do time deltas? Everywhere I look on Google for it, I see the C++ examples, which use sf::Clock and sf::Time, but I can't see any related classes for these for the C# bindings.
Am I being stupid, or are they named something different, or what? :v:
System.Diagnostics.Stopwatch :P
Looky here: [url]https://gist.github.com/arxae/6668686[/url]
Might not be the best code but meh :v: it's also for box2d, so ignore that stuff
Reset the stopwatch at the end of the update loop (or start at the beginning, stop at the end like here) and take the timespan. Then you have the amount of milliseconds for each frame.
[QUOTE=Arxae;45069422]System.Diagnostics.Stopwatch :P
Looky here: [url]https://gist.github.com/arxae/6668686[/url]
Might not be the best code but meh :v: it's also for box2d, so ignore that stuff
Reset the stopwatch at the end of the update loop (or start at the beginning, stop at the end like here) and take the timespan. Then you have the amount of milliseconds for each frame.[/QUOTE]
I tried something similar, but it just kept spewing zero at me.
[code] timer = Stopwatch.StartNew();
elapsed = timer.ElapsedMilliseconds;
long delta = elapsed;
while (app.IsOpen()) {
delta = timer.ElapsedMilliseconds - elapsed;
// Process events
app.DispatchEvents();
onThink(delta);
app.SetView(camera);
// Clear screen
app.Clear(windowColor);
app.Draw(circle);
Console.WriteLine("delta: " + delta);
// Update the window
app.Display();
elapsed = timer.ElapsedMilliseconds;
} //End game loop[/code]
Maybe I'm just being stupid again. :v:
[QUOTE=Gmod4ever;45069479]I tried something similar, but it just kept spewing zero at me.
[code] timer = Stopwatch.StartNew();
elapsed = timer.ElapsedMilliseconds;
long delta = elapsed;
while (app.IsOpen()) {
delta = timer.ElapsedMilliseconds - elapsed;
// Process events
app.DispatchEvents();
onThink(delta);
app.SetView(camera);
// Clear screen
app.Clear(windowColor);
app.Draw(circle);
Console.WriteLine("delta: " + delta);
// Update the window
app.Display();
elapsed = timer.ElapsedMilliseconds;
} //End game loop[/code]
Maybe I'm just being stupid again. :v:[/QUOTE]
pseudocode
[code]
Stopwatch SWatch = new Stopwatch()
SWatch.Start()
STUFF:
// DO STUFF
float Delta = (float)SWatch.ElapsedMilliseconds / 1000f //Convert milliseconds to seconds
SWatch.Restart()
GOTO STUFF
[/code]
[editline]11th June 2014[/editline]
to get current FPS you do
[code]
float FPS = 1f / Delta
[/code]
Just instantiate the stopwatch before the loop. At the start of the game loop you start it and at the end you stop it. Just before you stop it you take the elapsed time (it's a TimeSpan type)
OR
start before the game loop, restart at the end. Take elapsed time before restart.
Now the timespan object contains the deltatime (use the milliseconds property). You shouldn't need to do any subtraction :P
[code]
var stopwatch = new Stopwatch();
var elapsed = new TimeSpan(0);
stopwatch.Start();
while (app.IsOpen())
{
// Process events
// Clear screen
Console.WriteLine("delta: " + elapsed.Milliseconds); // this is your delta
Console.WriteLine("detailed delta: " + elapsed.TotalMilliseconds); // this is your delta in whole and fractional milliseconds
// Update the window
// get elapsed like this
elapsed = stopwatch.Elapsed;
stopwatch.Restart();
}
[/code]
I think this would be the easiest way to do it.
EDIT: i mixed up deltatime and frametime :v: as cartman300 said -> milliseconds/1000f -> deltaTime :P
please ignore this post.
[b]Baby Scripting[/b]
Does anyone know GML/Game Maker: Studio?
I need help from someone that does.
Before I crack my skull upon my desk.
[b]So[/b] I have this trigger in my game that, when entered, enables the player to click on a series of paper stacks that are nearby. When exited, it doesn't allow it anymore.
So the trigger has a creation event with the following code:
[code]globalvar paperstacksEnabled;
global.paperstacksEnabled = 0;[/code]
When the player collides with the trigger [code]global.paperstacksEnabled = 1;[/code] etc., you know.
The rest isn't really important at all because the variable is referenced by about 3 other paper stacks which all function correctly. However, for this one paper stack I changed the code to be totally encapsulated inside of a step event for better duplication and modularity for all of my other interactable objects.
So it's all enabled by this if statement in particular:
[code]if distance_to_point(mouse_x,mouse_y)<=0 && global.paperstacksEnabled == 1{[/code]
If the player's mouse is over the paper stack and the player is inside the trigger...
The loop never goes through.
When I have
[code]if distance_to_point(mouse_x,mouse_y)<=0{[/code]
The entire code works swimmingly however this has the unfortunate side effect of being able to click on the stack from anywhere which is not really what I wanted at all...
Obviously the previous if statement is reading paperstackEnabled as having a value of 0 at ALL TIMES NO MATTER WHAT.
So of course the first thing I do is look at the debugger to read the global value of paperstackEnabled while moving in and out of the trigger area just to see if something is fucking up.
When I'm out of the trigger:
[code]paperstackEnabled 0[/code]
When I'm in the trigger:
[code]paperstackEnabled 1[/code]
GASP, it's all just like it's supposed to be!
Furthermore, the other stacks have drag and drop (hate this stuff btw) events that each have a "mouse enter" event (equivalent to distance_to_point(mouse_x,mouse_y)<=0)).
An if statement is inside the running code:
[code]if global.paperstacksEnabled == 1{[/code]
The contents of that if statement run flawlessly.
Have I clearly defined the immense amount of bullshit this is?
Am I blind?
I'm fed up beyond fucking belief.
[editline]12th June 2014[/editline]
Come to think of it, I'm better off posting on the game maker forums.
If anyone has anything to say here though, it might help.
It might be a bug though because no matter how I look at the problem, it never makes sense as to how it's happening.
I could just be dumb though.
I want to make a program which hooks into a process and then once I press a selected button, it will simulate me pressing some other (multiple) buttons. The language is C#. Help please.
[QUOTE=RedCause;45082439]I want to make a program which hooks into a process and then once I press a selected button, it will simulate me pressing some other (multiple) buttons. The language is C#. Help please.[/QUOTE]
You don't need to hook the process, you can use SendKeys for that (but the other window has to be active).
[QUOTE=Tamschi;45082540]You don't need to hook the process, you can use SendKeys for that (but the other window has to be active).[/QUOTE]
Could you write the whole code? I'm not really familiar with c#, my friend just asked me to figure this out for him.
[QUOTE=RedCause;45083320]Could you write the whole code? I'm not really familiar with c#, my friend just asked me to figure this out for him.[/QUOTE]
This is not the 'code for me' thread. Either download a ready macro or pay someone to do it for you.
[QUOTE=RedCause;45083320]Could you write the whole code? I'm not really familiar with c#, my friend just asked me to figure this out for him.[/QUOTE]
The information I gave you should be enough for "your friend" with a few quick Google searches.
What's your budget and progress so far?
[QUOTE=Tamschi;45083544]The information I gave you should be enough for "your friend" with a few quick Google searches.
What's your budget and progress so far?[/QUOTE]
Im not sure, I just showed him the answers I got on this thread, Im not really into it, he just asked me for a favor to look this up for him.
[QUOTE=RedCause;45085980]Im not sure, I just showed him the answers I got on this thread, Im not really into it, he just asked me for a favor to look this up for him.[/QUOTE]
I'll do it for $30/hr.
Sorry, you need to Log In to post a reply to this thread.