• What do you need help with? Version 1
    5,001 replies, posted
I don't really get it, what is the code supposed to accomplish?
First time using WPF. Everything was working and then I start getting this exception. Doesn't point to any line in the code, just pops up that "No source available" tab and says this: 'The invocation of the constructor on type 'MainWindow' that matches the specified binding constraints threw an exception.' Line number '3' and line position '9'. These are the first few lines of the xaml: [cpp]<Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="371" Width="754" ResizeMode="NoResize" WindowStyle="SingleBorderWindow">[/cpp]
[QUOTE=Vbits;25904786]What Actually Happens when you try that? What does the definition of GameObject look like[/QUOTE] it works, but the physics example doesnt even look for collisions so i dont know how to keep track of it, maybe ill set plyCanJump = false then start a timer for 5 seconds then set plyCanJump = true
I'm trying to read from my settings file in VB.NET and execute the settings after they are read and parsed. But it's only ever executing the first line in the settings file, even though it's reading both lines. [b]Settings.cfg[/b] [code]default|C:\Users\Brian\Documents\Default.tlist startup|True[/code] [b]Code Regarding this Issue[/b] [code] If Not RepeatInstance Then NoteTimer.Start() Dim SettingsReader As System.IO.StreamReader = System.IO.File.OpenText(My.Application.Info.DirectoryPath + "\settings.cfg") Dim Settings As String = SettingsReader.ReadToEnd() SettingsReader.Close() Dim SettingsLines As String() = Settings.Split(vbNewLine) Dim Si As String For Each Si In SettingsLines Dim Sj As String() = Si.Split("|") If Sj.Count > 1 Then Select Case Sj(0) Case "default" DefaultFile = Sj(1) CurrentFile = DefaultFile If CurrentFile <> "" Then Dim Reader As System.IO.StreamReader = System.IO.File.OpenText(CurrentFile.ToString()) Dim File As String = Reader.ReadToEnd() Dim Lines As String() = File.Split(vbNewLine) Dim i As String For Each i In Lines Dim j As String() = i.Split("|") If j.Count = 3 Then Dim k As ListViewItem = Tasks.Items.Add(j.ElementAt(1)) k.ImageIndex = j.ElementAt(0) k.SubItems.Add(j.ElementAt(2)) End If Next i Reader.Close() MyBase.Text = "Urgency - " + CurrentFile.ToString() End If Case "startup" If Sj(1).Equals("True") Then Dim regKey As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True) regKey.SetValue("Urgency", Application.ExecutablePath) Startup.Checked = True Else Startup.Checked = False End If End Select End If Next Si Else MessageBox.Show("Repeat Instances not allowed.") Closeable = True Me.Close() End If [/code] It's reading both lines but it's not even entering the "startup" case even though the string should equate to "startup" but it never enters the case. I've used .startsWith and .Equals and neither of those work either.
I'm confused with function signatures. [cpp] int hey(int num1, int num2, int num3){ return num1+num2+num3 } int hey(float num1, float num2) { return num1+num2} registerfunction(hey) [/cpp] I need to be able to designate which of those I want
If you're wonderhing which "hey" function gets passed to registerfunction(), it's whichever one matches the type of parameter that registerfunction() is declared to take.
I want to specify which one gets passed.
You could probably do that via casting, like [cpp]registerfunction(static_cast<int (*)(float, float)>(&hey));[/cpp]
That doesn't make any sense, type-wise. You have one function that takes three ints and another that takes two floats. Your registerfunction() is going to either call the function it's given, or (probably) store it in a variable to be called later; there's nothing else useful that one can do with a function pointer. When something ultimately wants to call the registered function, how would it know what parameters to pass, if the code on the other side of that function pointer might expect either? Zeeky, casting doesn't solve the real problem. What use is having a pointer that lets you push two floats on the stack and then jump to some code that expects to find three ints on the stack? Jawalt, take a step back: what are you actually trying to accomplish?
[QUOTE=Wyzard;25926622]Zeeky, casting doesn't solve the real problem. What use is having a pointer that lets you push two floats on the stack and then jump to some code that expects to find three ints on the stack?[/QUOTE] Well, I guessed that the casting operator would select the better fitting method. Is this assumption wrong?
Not quite. The compiler can already select the appropriate function based on the declared type of registerfunction()'s parameter. I tried it with the cast and it works as long as the cast is to the same type that registerfunction() wants anyway, but the cast isn't really doing anything in that case. If I change registerfunction()'s parameter type to be void* and change the static_cast to a reinterpret_cast accordingly, GCC tells me "overloaded function with no contextual type information" on the line with the registerfunction() call. So no, the cast doesn't help with overload resolution.
Anyone know of a good tutorial regarding TCP/UDP sockets in C++? I have to write a simple file host for class in the coming weeks, but I just can't figure out where to get started with my socket classes and netcoding in C++ in general confuses me.
[url=http://johnnie.jerrata.com/winsocktutorial/][u]This[/u][/url] is a decent Winsock tutorial and [url=http://www.linuxhowtos.org/C_C++/socket.htm][u]this[/u][/url] looks like a nice tutorial for Unix sockets.
[QUOTE=sirbinks;25941336]Anyone know of a good tutorial regarding TCP/UDP sockets in C++? I have to write a simple file host for class in the coming weeks, but I just can't figure out where to get started with my socket classes and netcoding in C++ in general confuses me.[/QUOTE] [url=http://beej.us/guide/bgnet/]BAM[/url]
nice, thanks guys
Not sure if you guys will have any ideas about this but; i've been having this weird problem where my game (AS3) works fine but when i bring it into my browser (just by playing it in it or uploading it first) the collision messes up. I did some tests and i found it it was because with my hittests I offset them with the main's x/y position (to compensate for the camera movement) when i don't it works in the browser (and the CS3 IDE/ flash player) but not in the CS5 IDE/ flash player that came with it but when i do it's the opposite :S Is there something wrong with my version of CS5 or is it something else?
You can also look at boost::asio.
Is there a way to create a Random with a seed that isn't relying on time? I have this problem where my generator takes shorter than 1ms to complete it's actions and generate a new random number based on the current millisecond. (which obviously gives the same value again) The language is C#.
Maybe store the last random internally and then incorporate that into the next seed.
[url]http://pastebin.com/jy22i5dM[/url] Having a bit of a problem with this Ruby code. I've not used Ruby in quite some time so I've probably forgotten something.
[QUOTE=Dj-J3;25954319]Is there a way to create a Random with a seed that isn't relying on time? I have this problem where my generator takes shorter than 1ms to complete it's actions and generate a new random number based on the current millisecond. (which obviously gives the same value again) The language is C#.[/QUOTE] You should just seed the time once and use the generator without seeding again, should give you a different number
[QUOTE=Dj-J3;25954319]Is there a way to create a Random with a seed that isn't relying on time? I have this problem where my generator takes shorter than 1ms to complete it's actions and generate a new random number based on the current millisecond. (which obviously gives the same value again) The language is C#.[/QUOTE] As has been pointed out before, it does not "obviously give the same value again". It should give a new random number every time you call .Next().
Unless you're re-seeding every time. Common mistake.
Oh, that sorted it. Thanks :v: Should've tried that from the beginning. :sigh:
Yay I found the issue. There is no ++ or -- operator in Ruby :doh:
Im trying to make a ball have physics (or gravity actually), i want to use the sfml circle shape and inherit from it to make a class using the shape as a base and be able to add variables for mass, speed, direction... What would be the best way to do this? C++ and SFML btw
[QUOTE=Richy19;25960822]Im trying to make a ball have physics (or gravity actually), i want to use the sfml circle shape and inherit from it to make a class using the shape as a base and be able to add variables for mass, speed, direction... What would be the best way to do this? C++ and SFML btw[/QUOTE] [code] class MyBall : public sf::Shape::Circle { public: MyBall(/*etc*/); private: float mass, speed, direction; }; [/code]?
[QUOTE=Z_guy;25961207][code] class MyBall : public sf::Shape::Circle { public: MyBall(/*etc*/); private: float mass, speed, direction; }; [/code]?[/QUOTE] I read that the shape destructor has to be declared as virtual for it to work properly? unless it already is.
[QUOTE=Richy19;25961577]I read that the shape destructor has to be declared as virtual for it to work properly? unless it already is.[/QUOTE] Yeah, you're right. [code] virtual ~MyBall(); [/code]
Its giving me errors: Circle is not a member of sf::Shape Circle base class undefined sf is not a class or namespace circle base class undefined [editline]10th November 2010[/editline] On linux/codeblocks i get this error ball.cpp|5|error: expected class-name before &#8216;{&#8217; token Main.cpp [cpp]#include <iostream> #include <SFML/System.hpp> #include <SFML/Graphics.hpp> #include "ball.h" int main() { // Create the main rendering window sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Gravity Ball"); // Start game loop while (App.IsOpened()) { // Process events sf::Event Event; while (App.GetEvent(Event)) { // Close window : exit if (Event.Type == sf::Event::Closed) App.Close(); } // Clear the screen (fill it with black color) App.Clear(); // Display window contents on screen App.Display(); } return EXIT_SUCCESS; } [/cpp] Ball.h [cpp]#ifndef BALL_H_INCLUDED #define BALL_H_INCLUDED class MyBall : public sf::Shape::Circle { public: MyBall(); private: virtual ~MyBall(); }; #endif // BALL_H_INCLUDED [/cpp] Ball.cpp [cpp]#include <SFML/System.hpp> #include <SFML/Graphics.hpp> class MyBall : public sf::Shape::Circle { public: MyBall(); private: virtual ~MyBall(); }; [/cpp]
Sorry, you need to Log In to post a reply to this thread.