Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Lactose!

Member Since 16 Oct 2013
Online Last Active Today, 07:43 PM

#5240833 How do you write this down?

Posted by Lactose! on 16 July 2015 - 10:54 AM

I may be wrong, but isn't this equivalent?
 

while(x)
{
	int n = (v > 0 ? 1 : -1);

	x += n;
	y += (x - n);
	z += (y - n);

	if(doA()) doB();
}
Very hard to be sure without understanding what this does.

 

Doesn't seem equivalent to me. Firstly, x is never stated to have to reach 0. E.g. if v is positive and x is positive, nothing should happen (in the original code).

Additionally, the x, y and z things also seem wrong. I got this for the stuff inside the while loops:

int n = (x < 0) ? 1 : -1;
 
y += x;
z += y + n;
x += n;

I rejigged the order the variables are adjusted, so if the order is important in the actual code (it isn't in the posted snippet), then this wouldn't work.




#5240830 How do you write this down?

Posted by Lactose! on 16 July 2015 - 10:40 AM

 

[…] how do you solve the while clause?

if( v > 0 )

    while( x < 0 );

else

    whle( x > 0 );

while( abs(x + v) > 0) {
    // blah
}

What on earth are you doing?

 

That seems wrong to me.

v might be positive/negative 10000, while x might be positive/negative 5 -- the actual value of v doesn't matter, just whether it's positive or not.

In the posted code, v is never adjusted, while x is. In my example, the while loop should execute 5 times (given valid signs for x and v), which your abs version would not.




#5240650 Broken code

Posted by Lactose! on 15 July 2015 - 07:18 PM


Why?

If you have errors with your code, post the actual code that gives the error. Posting "cleaned up" code which doesn't contain the errors or show the full picture just makes everything harder when trying to help.

What you've posted omits too much to point to specific code other than guessing a lot.

 

That said, my guess is that "final" isn't a valid index for your deck_array. Why it isn't is a whole different question, which requires more information.




#5239708 Visual Studio Not Recognizing #include for SDL?

Posted by Lactose! on 11 July 2015 - 04:35 AM


Hey guys, issue was resolved. 

How?

Posting your solution might help others :)




#5239156 Bugs in code?

Posted by Lactose! on 09 July 2015 - 02:27 AM


but it's not working again..

Define "not working".

Helping someone is a lot harder when you don't know what the problem is.

 

EDIT:

That said, you're currently clearing the screen right before presenting it, which will essentially discard all rendering you've done before the clear.

 

You should also separate updating and rendering better than you do. Currently, you render the snake, then update it, then render other stuff -- I'd suggest updating everything that needs to be updated first, and then rendering everything that needs to be rendered after.

Additionally, your snake seems to have a lot of responsibilities -- updating time and input, spawning food, etc. For future projects, I would suggest splitting these responsibilities up further into additional classes. (See also: Single Responsibility Principle).




#5239076 Circular Header-Include Problem

Posted by Lactose! on 08 July 2015 - 04:23 PM


(Didn't want to post it because it's not the cleanest code).

If you have errors in your code, post your actual code. Sometimes posting a "cleaned up" version will remove the source of the error.

Also post the exact error messages you get, don't paraphrase them, etc. Simply saying "then the errors started appearing" doesn't give us enough information.

 

Don't be too worried about the quality level of your code. We all have code we can look back on and shudder at :)




#5238668 Collision detection and response

Posted by Lactose! on 06 July 2015 - 03:14 PM


2. Okay, so I now I basically know how to deal with a collision of an ellipsoid and a polygon (triangle, quad). Now what? Am I supposed to run the collision routine on every polygon in a mesh? If yes, it means I have to save the mesh data and not dump it after I upload it to the gpu, right? I really have no idea where to start.

Collision geometry can (and probably should) be different from render geometry. Collision geometry can in a lot of cases be made very simple compared to render geometry, which will reduce the amount of processing you need to do.

Additionally, there are ways of avoiding testing all polygons -- e.g. by partitioning areas in discrete chunks. A relevant search term here might be "Binary Space Partitioning (BSP)".

Optimizations here will depend on the type of games/level structure you need to have, though. A game like Metroid Prime (where you load and unload rooms as you traverse through them) can make a different set of assumptions and optimizations than an open world game like e.g. GTA V.




#5238486 optimisations for batch cartesian to polar?

Posted by Lactose! on 05 July 2015 - 04:38 PM

While not directly providing you with knowledge, I think answers to the below will help guide further replies to this post :)

 


i have a single core system and have a strong affectation for using optimisations, it's one of the things i enjoy most about coding.
 
for example a taylor series approximation may be sufficient if only a rough idea of angle is needed.

(Emphasis added)

 

Is only a rough idea of angle needed?

In other words, what are your current results, and what is your target? The more specific, the better.

 

You acknowledge that some optimizations can make your results less accurate, but potentially more performant. In the extreme ends of the spectrum, we've got A) Calculating everything with as much accuracy as is feasible and B) Returning a constant value regardless of input.

Where on that spectrum do you need to be? While there are probably tricks to maintain a specific accuracy while still increasing performance, knowing what your requirements are will help inform the choices and algorithms.

If the current accuracy is needed, have you considered profiling the amount of calls and see if you can reduce it? After all, the most performant code is the code that is never invoked!

You might just be converting a lot more than you need to do; this kind of conversion doesn't sound all to expensive to me.

 

On the other hand, it also sounds like you want this highly performant just because you want it to be (for the sake of enjoyment from optimazation), not because it needs to be. That's also valid, but keep in mind a lot of optimizations improve 1 or 2 of the following aspects, while decreasing the others:

1. Time to process.

2. Storage space.

3. Life-time spent on implementing.

 

Even in this case you'd need to decide how accurate it needs to be, while also having some sort of performance goal in mind.




#5238467 Does anybody NOT flip sprites in game?

Posted by Lactose! on 05 July 2015 - 01:44 PM

Josh Petrie and Onigiri Flash have already covered what I think about the question you asked, however...

 


organising the folder and exporting and saving each image takes almost as much time as drawing and animating a character

It sounds like your export & save process can be adjusted somehow. It might be possible to automate (parts of) this process, or streamline it, which would save you quite a lot of time.




#5237479 Understanding D3D11 basics

Posted by Lactose! on 29 June 2015 - 07:05 AM

What you pass through has to match what the shader expects to receive.

If the shader expects 2x Vector4 values per vertex (1 for position and 1 for color), then you need to supply that.

 

Different shaders can expect different things, for example a single vector position, and the color hard coded in the shader.




#5237476 Understanding D3D11 basics

Posted by Lactose! on 29 June 2015 - 06:58 AM

In the original code, we have the following:

{
New Vector4(0.0F, 0.5F, 0.5F, 1.0F), //Position of 1st vertex
New Vector4(1.0F, 0.0F, 0.0F, 1.0F), //Color of 1st vertex
New Vector4(0.5F, -0.5F, 0.5F, 1.0F), //Position of 2nd vertex
New Vector4(0.0F, 1.0F, 0.0F, 1.0F), //Color of 2nd vertex
New Vector4(-0.5F, -0.5F, 0.5F, 1.0F), //Position of 3rd vertex
New Vector4(0.0F, 0.0F, 1.0F, 1.0F) //Color of 3rd vertex
}

Positions are in X Y Z.

Colors are in RGBA (Red, Green, Blue, Alpha). Alpha tends to mean translucency in shaders like this.




#5237343 Memory management patterns in C++

Posted by Lactose! on 28 June 2015 - 04:56 PM


No commercial game engine uses garbage collection, but suddenly it's a great idea for someone making his own game engine? LOL
 
Unless I'm misunderstanding you, you're claiming that no game engine uses garbage collection. (The quoted sentence is a bit ambiguous depending on how one interprets sarcasm in text. It almost reads as if you're paraphrasing other posts, but I didn't get the same impression as what you post from any of the preceding posts.)
If you aren't actually claiming this, feel free to ignore the remainder of the post.
 
If you do claim this, though, it seems like a very bold claim. Would you care to share your definition of "a commercial game engine"?
As I see it, without looking up lists of engines and just going by what's on top of my head, both Unity3D and Unreal Engine 4 use garbage collection when you use them for development.
 
You previously disregarded the post about Unity3D, saying "There is a difference between using GC in a lnaguage that already has it, and implmenting it yourself.", which is true, but that also implicitly acknowledges that Unity3D uses garbage collection. More explicitly your follow-up posts also acknowledge Unity3D's garbage collection, even though you consider the engine to be "absolutely pathetic" when it comes to performance.
 
Unless you mean that the inner workings of game engines (by which I mean the parts you don't see while developing the game normally without looking at the game engine's source code) is made entirely without garbage collection.
That might very well be true, but even if it were true, I don't see how it matters when it comes to your claim.

---

I would agree that making your own garbage collection solution in C++ sounds like more effort and trouble than it's worth, though.

If you need a better solution than raw pointers, I would definitely look into just the "normal" smart pointers -- I would think they'd be enough for most use cases.

If you feel like they aren't, could you detail why not?




#5237148 Your thoughts on the value of profilers and debuggers?

Posted by Lactose! on 27 June 2015 - 03:13 PM

<snip>

 

 
Normally, I'd refrain from posting in this manner, but seeing as you're spewing forth vitriol in public, I wanted to set something straight, which I feel invalidates quite large chunks of your post.
 
 
I reported your post.
 
I reported it, because I do not think rape jokes belong on gamedev.net's forums. The fact that you, despite having your post removed and being given an official warning, choose to repost it here doesn't paint a pretty picture of you in my eyes (although you might not care about what I think of you, which is completely fair!).
 
In my report, I also wrote I thought the thread needed some cleaning up, as it was starting to turn into personal attacks and insults. This was not directed (only) towards your post, but at least parts of your post were out of line, in my eyes.
 
In your chat log(?) quote, you seem to think you would be able to step up and defuse the situation. However, proof being in the pudding, you seem to be escalating it instead (based on both this post and the reported post in question).
 
I am not a moderator. Thus, I tend to report stuff if I see something truly inappropriate/objectionable, if I think replying to it might lead to more off-topic posts and noise, leaving the moderating to the moderators.
You are also not a moderator, but you still seem to think you should decide whether people are fit to be a member or not. You are not the final arbiter of who deserves to be here, even though you throw insults and swear at people when you see fit, behaving like you are both judge, jury and executioner.
 
That isn't to say I think Graelig's posts are beyond reproach -- I have reported several of his* posts if I found them to be purely trolling, insulting or objectionable, after which I leave it to the moderators to actually deal with them, instead of being some sort of forum vigilante.
 
Nor is it to say I don't respect a lot of the posts you make -- you have tons of experience and a lot of your posts provide insight which can both spark interesting discussion and help others (including me).
I do not, however, blindly accept everything you post as gospel. If you (or anyone else, for that matter), post rape jokes or something else which I feel crosses the line, I will continue to report it to moderators for them to deal with (unless they ask me to stop, of course).
 
 
*Gender assumed.



#5237096 Restrict vector inside Circles?

Posted by Lactose! on 27 June 2015 - 08:31 AM

1. Get the magnitude of the vector.

2. If the magnitude is larger than 200 units, normalize it.

3. After normalizing the vector, scale it by 200 units.

 

The exact function calls will depend on what vector library you're using, but that should be more than enough to find it using Google :)

 

 

A quick note on step 2 which you can probably ignore: If this is code that needs to be very performant, you can optimize it slightly by checking if the squared magnitude is larger than 200 * 200 instead of what I described.




#5236715 [sfml] how to move object to exact distance using Time

Posted by Lactose! on 25 June 2015 - 06:36 AM


Velocity should be a scalar (ie single value).

Just to correct some terminology...

 

Velocity is a vector type. It has a direction and a magnitude.

Speed is a scalar type. It has only a magnitude.

 

A fairly easy mnenonic for this is Velocity = Vector, Speed = Scalar.






PARTNERS