Jump to content

  • Log In with Google      Sign In   
  • Create Account

Lactose!

Member Since 16 Oct 2013
Online Last Active Today, 04:19 PM

#5302384 What Programming Language And Libraries?

Posted by Lactose! on Yesterday, 05:00 PM

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

Err, what?




#5302240 Erasing Character

Posted by Lactose! 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 Lactose! 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 Lactose! 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 Lactose! 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 Lactose! 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 Lactose! 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 Lactose! 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 Lactose! 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 Lactose! 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 Lactose! 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.



#5297442 Breakout Animation for bricks.

Posted by Lactose! on 21 June 2016 - 07:38 AM

You could replace the "shown" variable inside brick with a "hiddenTimer" or something -- an initialize the timers so that the top-left one has a short timer and the bottom-right has a long timer.

When updating, decrement the hiddenTimer for each brick.

 

Then, when drawring, instead of "if (brick.shown)" you could do "if (brick.hiddenTimer < 0)".




#5297376 How to make a monitor?

Posted by Lactose! on 20 June 2016 - 03:43 PM

Render to a texture, and apply that texture to the monitor.

 

My internet is being super shoddy due to bad weather, or I'd try to find some links. Googling based on what I said should get you started.




#5296525 3D 8 directional sprite rotation based on facing direction relative to camera...

Posted by Lactose! on 14 June 2016 - 03:25 PM

arctan parameter order is usually (y, x) -- not (x, y).

 

Apart from that, I'd suggest just printing out some debug values as you spin the camera to see what values you get and compare them to what you are expecting to get, noting/looking into cases where the two differ.




#5296475 How to make spot lights in darkness for 2D games

Posted by Lactose! on 14 June 2016 - 08:18 AM

Very very useful tutorial : http://ncase.me/sight-and-light/ 

 

Fixed link: http://ncase.me/sight-and-light/

(Space was included at the end, causing a 404).






PARTNERS