Jump to content

  • Log In with Google      Sign In   
  • Create Account

Lactose!

Member Since 16 Oct 2013
Offline Last Active Today, 04:02 PM

#5303886 Best Way To Comment Code Without Cluttering

Posted by on 03 August 2016 - 06:47 PM

What I try to follow for my own code:

 

Write code that, for the most part, does not require comments. This includes proper names for things, keeping functions small & contained, dealing with as little code as it makes sense to do, keeping with the style of surrounding code, etc.

 

For algorithms or math heavy stuff I sometimes add a link in a comment, or copy the formula and information directly in comments if it doesn't take too much space.

 

Comment things that are out of the ordinary, or where the intuitive solution is not the correct solution.




#5303692 Only 12 Enemies, And My Fps Drops To 30, Why Is That?

Posted by on 02 August 2016 - 12:59 PM

Alvaro, but this is kind of what it does, because it gets the location of my gBones[] array in the vertex shader.
 

"get" usually implies that the function returns something. In this case, I would expect it to return an index/pointer or something. Actually this logic is what glGetUniformLocation follows -- it returns a location which you can store and use for something.

 

I'm not too fond of imposing guidelines on others, but I agree with Álvaro that the name is misleading.




#5303640 Only 12 Enemies, And My Fps Drops To 30, Why Is That?

Posted by on 02 August 2016 - 07:07 AM

Also, "losing/dropping" x frames per second is a relative thing.

If you're at 100 FPS normally, and drop 20 FPS, your frametime goes from 10ms to 12.5ms (2.5ms increase).

However, if you're at 40 FPS normally and drop 20 FPS, your frametime goes from 25ms to 50ms (25ms increase).

 

While for the end product the frame rate is probably a more important metric, while developing and finding bottlenecks it's mostly useless.




#5303357 How Can I Create A Successful Game In Unreal Engine

Posted by on 31 July 2016 - 01:47 PM

One step at a time.

 

Game development is hard.

There is no tutorial or step-by-step guide to making a successful game, in any editor or language.

 

There's also the issue of defining "successful". Released? Sold 10 copies? 100? 1 million?




#5302384 What Programming Language And Libraries?

Posted by on 24 July 2016 - 05:00 PM

I suggest Java programming.Because our computer games run owing to Java.

Err, what?




#5302240 Erasing Character

Posted by on 23 July 2016 - 05:56 PM

well here is a pong game I have developed, this shows that I can actually program, let me know what you think.

I'm not very keen on running random executables on my machine.

 

That said, you making a pong game before has absolutely nothing to do with the topic at hand.

To erase something visually, just stop drawing it. That's all there is to it.




#5302051 How To Make My Crosshair Red When Over An Enemy?

Posted by on 22 July 2016 - 05:37 PM

Can you give me something that is good for a start

A box might work. Another typical collider shape is a capsule.

Alternatively, several spheres stacked on top of each other -- if either of them are intersected, you've got a hit.




#5302034 How To Make My Crosshair Red When Over An Enemy?

Posted by on 22 July 2016 - 03:31 PM

When you shoot, how do you detect whether you hit?

I'd suggest performing the same kind of check (would guess some ray cast) and just use that.

 

If going that route, you could also cache the result, so you don't have to do another check when firing, but that might depend on your weapon (e.g. if you have a weapon with a high amount of spread, your crosshair might be red, even though bullets might miss).




#5301726 Debug With Gdb

Posted by on 21 July 2016 - 05:36 AM

got the previous crash without     ~Ausfaelle(); but with that I get undefined symbol and no crash. My app doesn't even load. undefined symbol: _ZN9AusfaelleD1Ev

 

~Ausfaelle(); is the declaration of a class destructor.

If you've declared it, you also need to define it (in the .cpp, like you do with the other normal class functions).

 

I would also suggest you use a debugger and step through, and see where the application crashes.

 

 

EDIT: That said, I don't see your class as needing a custom destructor. If you do not provide one, a default destructor is generated for you. You need a custom destructor in certain cases*, but I don't think your case requires one. I think something else is going on. Stepping through with a debugger seems like the best bet.

 

*Further reading here: Rule of three




#5300458 Why does this cause a memory leak?

Posted by on 12 July 2016 - 06:40 PM

I think this is because your std::vector is defined and lives at global scope. It gets destroyed when the application exits (at the end of/after main returns), but you check for memory leaks while the application is still running (inside main).

 

EDIT: Ninja Hodgman.




#5300113 UI Design Layout

Posted by on 11 July 2016 - 04:13 AM

Hey how did you do that cool google link thing.

http://lmgtfy.com/?q=how+to+google+that+for+you




#5299918 Finding that balance between optimization and legibility.

Posted by on 09 July 2016 - 05:30 PM

EDIT: I think I might have misunderstood this completely. Ignore the following :)

 

 

 

Usually, when this axis rotation function is invoked, it is called 3 times, once for each of the bases vectors x, y, z; The faster of the two implementation (2nd one) involves me defining float variables and calculating the sine and cosine values once in my my caller routine before invoking this function. However, this clutters my code more than I care for, as I would like my code to be more legible. With the solower implementation ( the first one), my code is less cluttered, and I don't have to track additional variables, but I am having to invoke the math function cosf() and sinf() 3 more times than normal, in mose cases:

Create a function that does that for you, then.

 

Instead of 

float sin = sinf(rads);
float cos = cosf(rads);
v3rot(v, vx, cos, sin); //first axis
v3rot(v, vy, cos, sin); //second axis
v3rot(v, vz, cos, sin); //third axis

Just do

myMoreEfficientRot(v, vx, vy, vz, rads);

Where that function is defined as:

void myMoreEfficientRot(v, vx, vy, vz, rads)
{
    float sin = sinf(rads);
    float cos = cosf(rads);
    v3rot(v, vx, cos, sin); //first axis
    v3rot(v, vy, cos, sin); //second axis
    v3rot(v, vz, cos, sin); //third axis
}

Or am I missing something?




#5298945 Making an object move back and forth.

Posted by on 03 July 2016 - 06:53 PM

Can you put this in code for me so I can copy and paste it?

 

This is my first game ever. Ive only been studing code for about a week now.

Sorry, no.

As I said, I don't remember the exact syntax, and I don't have Unity installed.

 

Edit:

That said, the steps I outlined should be fairly clear. Have you tried following them? If so, which step are you having trouble with?




#5298932 Making an object move back and forth.

Posted by on 03 July 2016 - 04:35 PM

 

awesome. ty. I will test this out :)

 

I'm currently using this script and I'm having problems.

 

    public float speed = 5;
 
    void Update()
    {
        transform.position = new Vector3(Mathf.PingPong(Time.time * speed, 10), transform.position.y, transform.position.z);
    }
 
I move the object to a position I want it. When I use Unity to play the game it moves my object to a different starting position than the one I positioned the object. LOL.  I have no clue why its repositioning it.
 
I hope someone can help me out. I'm going to experiment with the code you gave me up above.

 

It changes position because Mathf.PingPong returns a value from 0 to length (length in your case being 10).

 

I can't remember the exact syntax and I don't have Unity in front on me, but you could try...

- Create a new Transform variable (not public), startPos.

- On Awake or Start, set startPos to the current position. This should grab the position you set in the editor, and store it in startPos.

- On Update, do startPos.x + Mathf.PingPong() instead of just Mathf.PingPong(). This will take the start position, and then add in the PingPong motion on top of that.




#5298247 The latest BMP I made crashes the program, other BMPs work fine

Posted by on 27 June 2016 - 09:38 AM

It sounds like the crash is due to dereferencing a null pointer (since you could create an error message checking image == null). This is not the same as the image loader crashing your application.
The loader is probably failing to load the image, returning a null pointer, and your application doesn't handle this case properly.
 
One of the most common reason for failing to load an image is typing in an incorrect filepath/filename, so you should triple check that it's correct. Even if you're sure it's correct, check again.
 
Other than that, step through in a debugger and see where things go wrong.
 
 
EDIT:
Some additional advice;
Refer to the documentation to see what a function should return, and what is returned in the case of an error.
With that in mind, do error checking whenever possible. (For SDL this is usually checking for a null pointer and then calling some xxx_GetError function).
If you have problems with your code, post your code. Don't make us guess what might be the problem.
Learn how to use a debugger. This is a skill you will need as you progress. The sooner you learn, the better.





PARTNERS