• Create Account

# Thomas Wiborg

Member Since 05 Jan 2013
Offline Last Active Aug 15 2016 05:37 AM

### #5243911Mouse pointer out of applicationresolution when running fullscreen

Posted by on 31 July 2015 - 04:53 PM

If people wonder how i managed it.... I made this method.
Now my mousePos is scaling after the resolution. Works great.

```public Vector2 ReturnNewMousePosScale(float defaultComputerResolutionWidth, float defaultComputerResolutionHeight, float gameScreenWidth, float gameScreenHeight, Vector2 defaultMousePos)
{
Matrix ScaleMatrix = Matrix.CreateScale(defaultComputerResolutionWidth / gameScreenWidth, defaultComputerResolutionHeight / gameScreenHeight, 0.0F);

Vector2 Scale = new Vector2(ScaleMatrix.M11, ScaleMatrix.M22);

defaultMousePos = new Vector2(getMouseState.X, getMouseState.Y);

return defaultMousePos = defaultMousePos / Scale;
}```

### #5241294Pong. Reflection of ball intersecting paddle

Posted by on 18 July 2015 - 05:55 PM

The thing is. The A and B.. is that the edges?

Yes, those are the black arrows from my picture. Their values are up to you (tweaked on game design).
The values I used in the graph were Vector2( -0.707106781, -0.707106781 ) and Vector2( -0.707106781, 0.707106781 ) which is basically a normalized normal inclined -45° and 45° respectively

And how should i insert them into this method? Since it parameters is float?

There is a version that takes a Vector2. But even if it weren't, you actually just need to lerp every component of the vector (X and Y coordinates) individually (in other words, two lerp calls).

And what is this Amount in the function?

A value between 0 and 1. Think of it like 0% and 100%.
You can use the distance in the Y component from the position of the ball to the bottom edge of the paddle divided by the height of the paddle to get the value in the [0; 1] range.

Now I did all the job for you. You have the tools now. Time for you to think it through, experiment and figure some the few remainders for yourself. We learn through failure, not success. I only helped you because you seemed really stuck.

Thank you so much Matias. Yes I was EXTREMLY stuck
Ill give you a report on how its going

### #5121374Complete Beginner Programmer... where to start

Posted by on 05 January 2014 - 06:52 AM

Well,

Why dont you start with something simple as people have been refering to. Maybe C# combined with XNA. Its alot easier to start with a managed language, get comfortable with it and maybe try C++ later if you want to try an unmanaged language which most of the Game Industry uses.

But know that, games like Bloodline Champions, Terraria etc have been made with C# XNA. Nothing there stops you from

making great games with managed language.

Most elite programmers also have more than one language under theire belt. Over time learning different language is great to become even better!

### #5098707How C# computes Recursion

Posted by on 04 October 2013 - 03:29 AM

And ADP for trying to turn my head around in the right direction, like 100times, lol !

### #5098690How C# computes Recursion

Posted by on 04 October 2013 - 01:48 AM

Hello guys, I have this set of code

```class Factorial
{
public int Fac(int x)
{
if (x == 1)
{
return 1;
}
else
{
return x * Fac(x - 1);
}
}
}

static void Main(string[] args)
{
Factorial fac1 = new Factorial();
Console.WriteLine(fac1.Fac(4));
}
```

The thing is, I know how factorial works. Like 4! = 4*3*2*1 = 24

But i dont see how the computer computes it. The debugging and breakpoints make me more confused. Does anyone have the time to explain me in detail how this works?

One of my way of thinking is:

First iteration:
return x * Fac(x - 1);    = 4 * 3;
Second:
x * Fac(x - 1);              = 3 * 2
Third
x * Fac(x - 1);              = 2 * 1

But nothing returns 24.

Tho I know that in the end the computer does 4*6 = 24

Thomas

### #5080487Why companies still use C++ and what should I learn then

Posted by on 25 July 2013 - 11:10 AM

Many companies DON'T use C++ at all. In some industries the use of C++ is extremely rare or even completely denied simply because its not a very tolerant and safe language. In the game development world though, things are a bit different.

There are a few reasons why things are different in game development, and the biggest reasons have ABSOLUTELY NOTHING to do with performance. People to claim C++'s "performance" is the reason its used in game development couldn't be more wrong. The two biggest reasons C++ is used are:

• Legacy code, and lots of it.
• The platforms they're targeting (such as PS3/XBox/PS4/Xboner) ONLY support C and C++ targets (for AAA games).

Many AAA games are written, these days, targeting consoles first, and then ported over to the PC. There are big reasons for that, namely the number of units shipped is usually significantly higher for consoles than for the PC. When you're looking at shipping millions of units on a console versus hundreds of thousands on the PC it quickly becomes obvious which one is a better market choice. However, with the exception of XNA (and not long for that either), none of the current generation of consoles supports anything except for C and C++. Some games have been written in Scheme (GOAL actually), however those used a compiler that produced PS2 machine code that was written in house by the developers.

It is also important to understand that legacy code is a very big thing, you have libraries that manage resources, libraries that manage memory, various forms of standard libraries (containers, algorithms, etc) that have all been written over the years using C and C++. Thus it is important, from a business perspective, to squeeze as much value as you can from those artifacts. Thus the legacy aspect comes into play. If you look at something like EA Sports... they've been hammering at the same code base for nigh unto a decade now. That's a huge amount of functionality and code that has been produced which would need to be tossed and rewritten should they move to another software platform (such as .Net), assuming one even existed for their target consoles.

As for what languages you should learn first? Your goal as a newbie programmer is to learn PROGRAMMING. Not optimization, not a programming language, not "low level" nonsense that people like to claim is the benefit of learning C++ first. No, your goal is to learn to program. Software development. The art and method of solving problems through strategic application of algorithms, data structures, and logic. This skill is independent of ALL languages, but it is EASIEST to pick up when you start with a language that is EASY TO LEARN. C++ is NOT THAT LANGUAGE. C#, Java, Python, Lua... all of these are great starting points that can help you to get started and rapidly develop the appropriate thought processes, which you can then apply to learning a significantly more complex beast, like C++.

For those recommending C++ as a first language, here's a simple little quiz. Take it if you dare. Try not to cheat. I.e. answer off the top of your head, not with your compiler or with a textbook.

• Given the following three lines of code, answer these questions
• Is the second line well defined behavior?
• If the second line is well defined, where does the pointer point to?
• What are some of the legal operations that can be performed on the third pointer?
• ```int* p = new int[10];
int* j = p + 11;
int* k = p + 10;```
• What output should the following lines of code produce?
```int a = 10;
std::cout<<a<<a++<<--a;
```
• Assuming the function called in the following block of code has no default parameters, and that no operators are overloaded, how many parameters does it take? Which objects are passed to it?

`f((a, b, c), d, e, ((g, h), i));`

Lastly, here's a list of links to similar threads on this issue:

This one enjoys fairly significant popularity. (Note that only threads containing significant discussion are included.)

1) Professional Games Made In C#?
2) Java for game development?
3) Java----C/C++
4) c++ or c#
5) Question about Java Vs. C# Vs. C++
6) Java Games?
7) Java is fast?
8) Secondary Language:VB or Java?
9) What makes C++ so powerful?
10) C# games and cheating...
11) Is C# good enough for system utility programming
12) MC++ vs. C#
13) Which language is best for a 3d Games Engine?
14) C# vs C++ as a choice for development
15) Is Java the Future?
16) why C# and not Java?
17) What do you think of the D language?
18) my c++ d c# benchmark!
19) The Definitive Guide to Language Selection
20) Sharp Java
21) C++ or C#?
22) C++ or C#?
24) C++ or C#?
25) Visual C++.net vs Visual C#.net
26) C# - huh?
27) which language should i learn?
28) C or C++ or C#
29) learn C or C++ ??
30) Is C still useful in gamedev?
31) Why C# XNA When Everyone Wants C/C++
32) JIT compiled code vs native machine code
33) C++ or C?

This particular list is my top ten, because of the sheer frequency with which they occur. 12 days, 10 threads.
1) c++ or c# (5/1/06)
2) Java for game development? (5/2/06)
3) Java Games? (5/3/06)
4) Java----C/C++ (5/3/06)
5) MC++ vs. C# (5/4/06)
6) What makes C++ so powerful? (5/9/06)
7) C# games and cheating... (5/9/06)
8) Is C# good enough for system utility programming (5/9/06)
9) Which language is best for a 3d Games Engine? (5/11/06)
10) C# vs C++ as a choice for development (5/12/06)

I realy enjoy what you are saying!
To me it seems like people are only focusing C++ just because industry like Blizzard, Riot, Bethesda, EA and others are using it.
Cause alot of us just want to stay Indie and make marvelous games that way, no need for C++.

I also believe that C++ is still used by big companies because it would cost and take tremendous of time switching to another language.
Why should they when they can get the same result using C++ as with C#...
Maybe things will change, but atm its no reason for the industry to waste time/money changing language.

Dont tell me that C# wouldent do the same trick making for example League Of Legends...
Bloodline Champion is an AAA game made with C#/XNA.

PARTNERS