Alright, thanks for your help, but I managed to find the problem:
main.cpp needed to include test.cpp.
:rolleyes:
No. No. No. CPP files don't include other CPP files.
Then, what am I [I]supposed[/I] to do?
Can you upload your CodeBlocks project + source?
Or confirm that you've added test.cpp to the project source tree.
have you added #include "test.h" to test.cpp
- snip -
EDIT:
Okay, I discovered the real problem now. I wasn't properly linking the .cpp file to debug and release compile categories.
[QUOTE=Doohl;33049533]main.cpp needed to include test.cpp.[/QUOTE]
I couldn't of been the only one who cringed when I read this.
Yeah, I know, I did a bit of reading after I said that. Now, I feel very, very dumb!
I feel like an idiot asking this, but I'm making a flash game and I'm kinda stuck here. How would I go about making my character fire bullets?
What I mean is, how do I spawn a movieclip at the x and y of my player and how would I handle collisions with the enemy since there would be several movieclips with the same instance? I assume I'd have to number the instances somehow but how would I reference those? Bah.
I'm working in AS2, by the way.
How do I move an object in a direction based on an angle in 2D space? My math sucks.
[QUOTE=farmatyr;33055829]How do I move an object in a direction based on an angle in 2D space? My math sucks.[/QUOTE]
Object's x increases by distance*cos(angle) and y increases by distance*sin(angle).
[QUOTE=sim642;33055876]Object's x increases by distance*cos(angle) and y increases by distance*sin(angle).[/QUOTE]
Thanks!
I didn't get it working at first, turned out I was working with degrees. Stupid me.
C#
[del]Is there some event for when you bring a form to the front?[/del]
I found Form.Activated.
Now my next question is: I have two forms main and second.
When I focus my main Form, I want the second one to also show, but not be focused.
Can anyone tell me how to properly draw in gwen.NET using the XNA renderer someone on here wrote? I keep getting a NullReferenceException when i call the Canvas.RenderCanvas() method.
[img]http://puu.sh/7THy[/img]
[editline].[/editline]
Fixed that. Turns out i have to set the renderer's Content member to the xna game's ContentManager.
Now i have another problem though. My screen is empty, even though i've added a test button control.
[cpp]var button = new Gwen.Control.Button(this.gui.Canvas);
button.SetBounds(10, 10, 200, 100);
button.SetText("Hello world");[/cpp]
Any ideas?
[editline].[/editline]
Fixed it, i forgot to draw the render target :downs:
[QUOTE=vexx21322;33057512]C#
[del]Is there some event for when you bring a form to the front?[/del]
I found Form.Activated.
Now my next question is: I have two forms main and second.
When I focus my main Form, I want the second one to also show, but not be focused.[/QUOTE]
[code]
Form2.Show();
Form1.Focus();
[/code]
[QUOTE=NovembrDobby;33058938][code]
Form2.Show();
Form1.Focus();
[/code][/QUOTE]
Forgot to mention, the second form is already shown. I want the second form to act 'docked' to the main form.
just spam setlocation or w/e C# uses to the firsts window X + width.
C# should have a focus event, so whenever the first window is focused, focus on second then focus on first again.
I learned this when making my ds clone :v:
Making gui things in python, when I create a button to close the frame (command=frame.quit), it just crashes instead of closing, and I get the "pythonw isn't working blah blah". Is there a way to stop this or another command I should be using to close the window?
[QUOTE=Map in a box;33060319]just spam setlocation or w/e C# uses to the firsts window X + width.
C# should have a focus event, so whenever the first window is focused, focus on second then focus on first again.
I learned this when making my ds clone :v:[/QUOTE]
It already has the dock behaviour, but if a window goes over the second form and I re-focus the main form, the second form remains behind said window.
I've tried setting .Focus() on the second form, then on the first form, but when I focus the main form, the Activated event fires twice and the second form is still focused.
[QUOTE=vexx21322;33060620]It already has the dock behaviour, but if a window goes over the second form and I re-focus the main form, the second form remains behind said window.[/QUOTE]
It sounds to me like you want to make one form a "parent" of the other. Sort of embedding one form into the other.
You can import the Win32 function "SetParent" like so:
[csharp]using System.Runtime.InteropServices;
...
[DllImport("user32.dll")]
static extern public IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);[/csharp]
Call it like this:
[csharp]SetParent(Form1.Handle, Form2.Handle);[/csharp]
Does anybody know how processors exponentiate floating-point numbers?
I.e. what's the algorithm for 5.124e2 ^ 1.23e1 = 2.13e33, in terms of mantissa, exponent, and +,-,*,/ operations?
[QUOTE=jalb;33061142]It sounds to me like you want to make one form a "parent" of the other. Sort of embedding one form into the other.
You can import the Win32 function "SetParent" like so:
[csharp]using System.Runtime.InteropServices;
...
[DllImport("user32.dll")]
static extern public IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);[/csharp]
Call it like this:
[csharp]SetParent(Form1.Handle, Form2.Handle);[/csharp][/QUOTE]
Do I have to SetParent when both forms are visible? Otherwise, it's not working for me.
[QUOTE=vexx21322;33061868]Do I have to SetParent when both forms are visible? Otherwise, it's not working for me.[/QUOTE]
I believe so. This is what I tried:
[url]http://pastebin.com/ZUJuDhQF[/url]
[img_thumb]http://dl.dropbox.com/u/11093974/Junk/setparent.png[/img_thumb]
[QUOTE=Nikita;33061794]Does anybody know how processors exponentiate floating-point numbers?
I.e. what's the algorithm for 5.124e2 ^ 1.23e1 = 2.13e33, in terms of mantissa, exponent, and +,-,*,/ operations?[/QUOTE]
I imagine they use some optimized methods which are based on just calculating floating point powers of two and logarithms in base 2. Those two functions are relatively simple to implement with just integer arithmetic, and they allow you to calculate other powers easily:
a^b = 2^(log2(a) * b)
In fact I think I have some implementations of them lying around on my home computer, but I can't reach it until the next weekend. They were fun to implement so I suggest you try it yourself.
I have an object, and I have the angle in radians that the object is facing. How do I make this object move forward/backwards in the direction the angle is facing?
Having some difficulty with loops in Python. It's been stumping my entire class.
[code]def pattern(index):
n = raw_input("Please enter a whole integer ")
if n.isdigit:
print n
while index < 10:
print n
n = n + 1
index += 1
else:
input("Please press enter to exit")
else:
print ("Please try again")
return pattern(index)
index = 0
pattern(index)
[/code]
The goal to is to use loops, I'm supposed to take an integer as an input, check that it's an integer,
and print the next 10 in sequence.
However
[quote]TypeError: cannot concatenate 'str' and 'int' objects[/quote]
I would love to use just the input method, but my teacher banned me from using exceptions, so I'm wondering how to do value checking? I'm supposed to print an error if the user does not input an integer.
-snip-
[QUOTE=PieClock;33063414]I have an object, and I have the angle in radians that the object is facing. How do I make this object move forward/backwards in the direction the angle is facing?[/QUOTE]
You can use the trigonometric functions "sine" and "cosine" to do this. It's actually quite simple!
[csharp]x += cos(direction) * speed;
y += sin(direction) * speed;[/csharp]
Depending on how it's setup you might have to play with the plus and minuses.
You flip the signs to go backwards:
[csharp]x -= cos(direction) * speed;
y -= sin(direction) * speed;[/csharp]
edit: Been so long since I've actually used this. I believe you subtract sin() from y rather than add it.
[QUOTE=Map in a box;33035072]What am I doing wrong? This is my shunting yard algo in java:
[code]
for(int I=0;I<tokens.length;I++){
String token=tokens[I];
if(operators.containsKey(token)){
Operator O1=Operator.fromOperator(token);
Operator O2;
if(stack.size()!=0)
while((O2=Operator.fromOperator(stack.get(stack.size()-1)))!= null)
if((O1.isRightToLeft&&O1.precedence<O2.precedence)||(!O1.isRightToLeft&&O1.precedence<=O2.precedence)){
output+=O2.operator+" ";
stack.remove(stack.size()-1);
}
stack.add(token);
}else if(token.equals("(")){
stack.add(token);
}else if(token.equals(")")){
String tkn="";
while(!(tkn=stack.get(stack.size()-1)).equals("(")){
stack.remove(stack.size()-1);
output+=tkn+" ";
}
stack.remove(stack.size()-1);
}else{
output+=token+" ";
}
}
[/code][/QUOTE]
Repost of hope and prosperity
Fixed, here's the final code, in case anyone wants it.
[lua]
function love.load()
graphic_car = love.graphics.newImage("images/car.png")
car = {}
car.x = 400
car.y = 300
car.angle = 0
car.speed = 5
end
function love.update()
if love.keyboard.isDown("a") then
car.angle = car.angle - 0.1
elseif love.keyboard.isDown("d") then
car.angle = car.angle + 0.1
end
if love.keyboard.isDown("w") then
car.x = car.x + math.cos(car.angle) * car.speed
car.y = car.y + math.sin(car.angle) * car.speed
elseif love.keyboard.isDown("s") then
car.x = car.x - math.cos(car.angle) * car.speed
car.y = car.y - math.sin(car.angle) * car.speed
end
end
function love.draw()
love.graphics.draw(graphic_car, car.x, car.y, car.angle, 1, 1, 10, 5)
end
[/lua]
Sorry, you need to Log In to post a reply to this thread.