What does dx and dy represent? Atan2 will return the angle between two vectors (Correct me if I'm wrong), so you have to pass two vectors and not x and y. I'm basing this around this old implementation I found laying on my projects folder, it works, but I'm not sure if it can be useful to you.
[csharp] public static double CalculateAngle(Vector2 vector1, Vector2 vector2)
{
return Math.Atan2((vector2.Y - vector1.Y), (vector2.X - vector1.X));
}[/csharp]
Atan2 is the same as Atan(y/x). Which reminds me, you have dx and dy the wrong way round in the Atan2 call.
I´ve got movement for my spaceship figured out, but how would I do the same thing for sidewards rotation?
[code]
shuttlePos += new Vector2((float)(Math.Cos(angle - (Math.PI / 2)) * movementSpeed), (float)(Math.Sin(angle - (Math.PI / 2)) * movementSpeed));
[/code]
C# and XNA
I'm trying to learn C.
[code]
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int var1;
int var2;
sum;
printf("Enter your number:");
scanf("%d, &int1");
scanf("%d, &int2");
sum = var1 + var2;
[b]printf(sum);[/b]
getch();
return 0;
}
[/code]
I compile and run that and it crashes when it trys to print out 'sum'
You have to declare sum as an int, so int sum; instead of just sum;
[QUOTE=WTF Nuke;32683043]You have to declare sum as an int, so int sum; instead of just sum;[/QUOTE]
Oh sorry, I did, but it didn't paste into my post for some reason.
This is the fixed version
[code]
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int var1;
int var2;
int sum;
printf("Enter your number:");
scanf("%d, &int1");
scanf("%d, &int2");
sum = var1 + var2;
printf(sum);
getch();
return 0;
}
[/code]
I don't know C well, but don't you have to do printf("$d, sum") or something?
[QUOTE=LieutenantLeo;32683099][code]
scanf("%d, &int1");
scanf("%d, &int2");[/code][/QUOTE]
What are you even
[code]
scanf("%d", &int1);
scanf("%d", &int2);
[/code]
[QUOTE=WTF Nuke;32683134]I don't know C well, but don't you have to do printf("$d, sum") or something?[/QUOTE]
That time it printed out "$d, sum" and didn't crash. It seems like when it tries to print the value of sum, it just crashes.
[editline]8th October 2011[/editline]
[QUOTE=esalaka;32683199]What are you even
[code]
scanf("%d", &int1);
scanf("%d", &int2);
[/code][/QUOTE]
I saw that in a tutorial online. It's probably wrong.
[QUOTE=LieutenantLeo;32683235]It seems like when it tries to print the value of sum, it just crashes.[/QUOTE]
That's because what you're doing is equivalent to printf((char *)sum);
You should be doing printf("%d", sum);
[editline]8th October 2011[/editline]
Essentially what you were doing was discarding two input numbers, then getting the sum of two uninitialized integers and trying to use it as a pointer to a string.
That's just
[QUOTE=esalaka;32683269]That's because what you're doing is equivalent to printf((char *)sum);
You should be doing printf("%d", sum);
[editline]8th October 2011[/editline]
Essentially what you were doing was discarding two input numbers, then getting the sum of two uninitialized integers and trying to use it as a pointer to a string.
That's just[/QUOTE]
That works.
[editline]8th October 2011[/editline]
Wait, what the fuck? Now whatever I enter it always calculates to 68 lol.
[QUOTE=LieutenantLeo;32683099]Oh sorry, I did, but it didn't paste into my post for some reason.
This is the fixed version
[code]
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int var1;
int var2;
int sum;
printf("Enter your number:");
scanf("%d", &var1);
scanf("%d", &var2);
sum = var1 + var2;
printf("%d", sum);
getch();
return 0;
}
[/code][/QUOTE]
Fixed your code.
What resources would you guys suggest to learn vim? I love the concept, especially for laptop use where trackpads aren't fantastic to use in that way.
[QUOTE=AMD 32;32684679]What resources would you guys suggest to learn vim? I love the concept, especially for laptop use where trackpads aren't fantastic to use in that way.[/QUOTE]
[url=http://vim.wikia.com/wiki/Vim_Tips_Wiki]This[/url] and just using it. You might want to read a book about vi or vim as well, go check your local library for one.
[QUOTE=AMD 32;32684679]What resources would you guys suggest to learn vim? I love the concept, especially for laptop use where trackpads aren't fantastic to use in that way.[/QUOTE]
I use it on my netbook, but I honestly never read much up on it. Using gentoo, and I decided to just go with it and emerged vim :v:
How do you change the themes on microsoft visual C#? When I program at night, the bright theme can hurt my eyes, and I think a darker change would be nice.
[QUOTE=Mr. Smartass;32689710]How do you change the themes on microsoft visual C#? When I program at night, the bright theme can hurt my eyes, and I think a darker change would be nice.[/QUOTE]
Tools > Options > Environment -> Fonts and Colors
[QUOTE=ief014;32689900]Tools > Options > Environment -> Fonts and Colors[/QUOTE]
Thanks! Is there any way to change the coloring of the windows that aren't directly the actual code editor, such as the properties window, the solution explorer, ect?
Fuck, I thought I fixed my jump code, but I haven't. My gravity doesn't scale linearly with frame time. I fall down a lot slower, and don't slow down as fast when going through high gravity areas (gravity = the higher the slower you fall and jump). Would love it if you can point out where I did stupid things.
[cpp] if (jumpvelocity < 0){
yvelocity = jumpvelocity * t *2;
jumpvelocity += 185.f*t * 2 / gravity;
}
else if(!grounded ){
if(yvelocity < terminaly)
yvelocity += t / gravity;
else
yvelocity = terminaly;
}
else{
yvelocity = 0.f;
}[/cpp]
[QUOTE=Mr. Smartass;32690032]Thanks! Is there any way to change the coloring of the windows that aren't directly the actual code editor, such as the properties window, the solution explorer, ect?[/QUOTE]
I tried out [url=http://stereopsis.com/flux/]f.lux[/url] on my Win7 install yesterday and it seems pretty good. It changes the colour warmth of your whole screen depending on the time, so when it's late at night it's less like artificial lighting. I suggest you try that and see if that helps.
I also tend to use complete fullscreen text editing at night, without any menu or toolbars or anything. I find that helps because my style is coloured text on a black background, and if there are white toolbars they're very blinding. This approach may not work for you.
I'm still having troubles getting performance where I want it to be in my game which I'm making in Pygame. I have a lot of images which don't change that get blitted to the screen, at first I was blitting them every time the game looped but as the amount of them increased performance drastically dropped.
So I decided to blit them to the screen before my game loop started along with my background. But the problem is that my character image/rect need to be blitted to the screen each time the game loops and since my background/other images aren't re-blitted my character has a trail from the previous time he was blitted.
[QUOTE=SourBree;32693386]I'm still having troubles getting performance where I want it to be in my game which I'm making in Pygame. I have a lot of images which don't change that get blitted to the screen, at first I was blitting them every time the game looped but as the amount of them increased performance drastically dropped.
So I decided to blit them to the screen before my game loop started along with my background. But the problem is that my character image/rect need to be blitted to the screen each time the game loops and since my background/other images aren't re-blitted my character has a trail from the previous time he was blitted since it doesn't have any other images over it because the other images aren't blitted every game loop.[/QUOTE]
I don't really know much about python and pygame, but you can try checking whether an image is within the view. If it's not, don't bother blitting it. If it is, the player needs to see it, so blit it then. This drastically improved the performance of one of my little test games. I don't have exact figures for the performance increase but it was significantly faster.
[QUOTE=Mr. Smartass;32690032]Thanks! Is there any way to change the coloring of the windows that aren't directly the actual code editor, such as the properties window, the solution explorer, ect?[/QUOTE]
There should be a dropdown above the font selection where you can select the window the settings apply to. At least in Visual Studio 2010, not sure if it's also for express editions.
Does anyone know of a lib that can do cross-platform x360 controller input? All I can find are individual [url=http://pingus.seul.org/~grumbel/xboxdrv/]libs[/url] [url=http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/OsxDriver]and[/url] [url=http://www.codeproject.com/KB/directx/xbox360_cont_xinput.aspx]stuff[/url] for different platforms
[QUOTE=NovembrDobby;32696483]Does anyone know of a lib that can do cross-platform x360 controller input? All I can find are individual [url=http://pingus.seul.org/~grumbel/xboxdrv/]libs[/url] [url=http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/OsxDriver]and[/url] [url=http://www.codeproject.com/KB/directx/xbox360_cont_xinput.aspx]stuff[/url] for different platforms[/QUOTE]
Direct X makes a lot of really stupid assumptions about gamepads/joysticks, so they pretty much forced themselves to re-invent the wheel when they tried to add 360 controller support.
Linux, and pretty much every other reasonable OS is going to treat a 360 controller like any other control pad. It'll be easier (and better) to find something more generic.
Alright, I have 2 questions: (OpenTK, C#)
1. In my game, I'm drawing a shadow by drawing a transparent black circle texture on the floor beneath the ball, which looks fine, but now I'm trying to make the shadow less visible the higher the ball is from the floor. However, since I'm using multiply blending, setting the alpha of the shadow has no effect on the darkness of it. This is the blend mode I'm currently using:
[cpp]GL.BlendFunc(BlendingFactorSrc.Zero, BlendingFactorDest.SrcColor);[/cpp]
Does anyone know what I'd need to add here to make alpha influence the darkness of the shadow?
2. My ball raycasts downwards to the floor to determine the shadow position, which works fine, but it also returns a normal vector I'd like my shadow to adjust to. However, the problem is, my shadow model stores rotations in quaternions, and I have no idea how to convert this normal vector into a quaternion. Any help here?
In c++, does fstream pick up where it last left off? For example, my program reads a few characters from a line in a text file, if I want a function to grab the rest of the line, can I just do a getline and it will finish the line where the main left off?
Yes.
[QUOTE=Dlaor-guy;32698951]Alright, I have 2 questions: (OpenTK, C#)
1. In my game, I'm drawing a shadow by drawing a transparent black circle texture on the floor beneath the ball, which looks fine, but now I'm trying to make the shadow less visible the higher the ball is from the floor. However, since I'm using multiply blending, setting the alpha of the shadow has no effect on the darkness of it. This is the blend mode I'm currently using:
[cpp]GL.BlendFunc(BlendingFactorSrc.Zero, BlendingFactorDest.SrcColor);[/cpp]
Does anyone know what I'd need to add here to make alpha influence the darkness of the shadow?
2. My ball raycasts downwards to the floor to determine the shadow position, which works fine, but it also returns a normal vector I'd like my shadow to adjust to. However, the problem is, my shadow model stores rotations in quaternions, and I have no idea how to convert this normal vector into a quaternion. Any help here?[/QUOTE]
1) try some other values for the blendfunc, here's mine from most projects:
[csharp]GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);[/csharp]
This is a good explanation of BlendFunc: [url]http://www.bigpanda.com/trinity/article2.html[/url]
2) Quaternion.FromAxisAngle(Vector3 axis, float angle) maybe?
[QUOTE=Dlaor-guy;32698951]In my game, I'm drawing a shadow by drawing a transparent black circle texture on the floor beneath the ball, which looks fine, but now I'm trying to make the shadow less visible the higher the ball is from the floor. However, since I'm using multiply blending, setting the alpha of the shadow has no effect on the darkness of it.[/QUOTE]
Change the color of the shadow instead. Multiplying anything by black yields black, and multiplying by white leaves the original color unchanged. Multiplying by various shades of gray produces various shades of darkening.
Sorry, you need to Log In to post a reply to this thread.