• What Do You Need Help With? V6
    7,544 replies, posted
Apologies if this isn't the right thread, but I couldn't a general discussions thread, so here goes. A friend of mine and I have decided to learn to code. What would be a good language (or good languages) for us to pick up? From what I've heard, C# is powerful and Java kind of sucks. C++ seems really common and useful, but my friend tells me it's obnoxious to learn. This might be outside the scope of programming languages and more in the realm of scripting (if there is a difference; pardon me if there isn't), but a coding language that can be used to quickly and easily guillotine and reassemble images en masse would be convenient for me. I believe Javascript can do this, but I'm not terribly interested in JS.
[QUOTE=E-102 Gamma;40030889]Apologies if this isn't the right thread, but I couldn't a general discussions thread, so here goes. A friend of mine and I have decided to learn to code. What would be a good language (or good languages) for us to pick up? From what I've heard, C# is powerful and Java kind of sucks. C++ seems really common and useful, but my friend tells me it's obnoxious to learn.[/QUOTE] C# is easy to learn and has a lot of features that make commonly used patterns a bit easier. Java is basically the same with a bit less features and things that work slightly differently in a slightly bad way, the main difference is that it lacks certain features that are somewhat important for game programming (like custom value types) and the runtime is a lot worse. It's slightly more verbose than C#. There's also a lot of badly written applications which usually doesn't help the opinion of the language. C++ is by far more powerful in the things you [I]can[/I] do if you put in the work to implement them. It's a lot more verbose than the other two though (unless you use templates or whatever C++ metaprogramming is called), and harder to debug (from what I've seen, someone correct me if there's a debugger as good as the C#/Java ones). C++ has manual memory management, which means it's easier to create mistakes from omission that can bring down the program. With good safe (safe typecasts, memory handling) it's probably not more error prone than the others, but it's more difficult to learn. [QUOTE]This might be outside the scope of programming languages and more in the realm of scripting (if there is a difference; pardon me if there isn't), but a coding language that can be used to quickly and easily guillotine and reassemble images en masse would be convenient for me. I believe Javascript can do this, but I'm not terribly interested in JS.[/QUOTE] This is not really a language feature, it goes more in the direction of libraries. [del]Neither of the standard libraries of these languages have that feature I think[/del], but it's likely that there's a library that does this. C# can use C++ libraries relatively painlessly, Java needs C++ code or [URL="https://github.com/twall/jna/"]another library[/URL]. C++ has libraries for just about anything but they aren't always easy to get working if you're on Windows. You could also have a look at Python. It's not as commonly used for desktop applications as the three above, but it's very easy to learn and has a very good debugger in eclipse. There's a library for almost everything [URL="http://xkcd.com/353/"]from what I've heard[/URL]. Python is closer to being a scripting language in that it's often less verbose, but most of the object oriented paradigms still apply. I only used it very briefly, but it definitely lets you get things done quicker than C# or Java. If you use the IDE Eclipse, there's [URL="http://pydev.org/"]very good Python integration[/URL]. For C# get Visual Studio (probably free if you're a student at university/college otherwise get the [URL="http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-for-windows-desktop"]Express Edition[/URL]), for Java [URL="http://www.eclipse.org/"]Eclipse[/URL] and [URL="http://netbeans.org/"]Netbeans[/URL] are good. For C++ it's probably Visual Studio on Windows, but I haven't used it so far. When you start something that's a bit larger or you want to work together on a project, get a distributed version control system like [URL="http://mercurial.selenic.com/"]Mercurial (Hg)[/URL] or [URL="http://git-scm.com/"]Git[/URL]. Mercurials GUI is a lot better than Git's (which is more focused on the command line than Hg) and it's slightly easier to learn. (All this is low priority though, first learn the basics of programming, then read a lot about one of the version control systems before you accidentally lose days of work.) You can also switch languages later once you've got the basics, C# and Java are interchangeable in a lot of ways (it's possible to start a Java job coming from C# after reading up on the differences, if you can look up the libraries on the fly), C++ is pretty similar apart from the manual memory management and Python mostly just looks different when compared to the first two. Edit: [URL="http://stackoverflow.com/a/10657449/410020"]There's a library for Python that makes your image editing task very easy.[/URL] Start with the language basics though. [URL="http://stackoverflow.com/questions/465172/merging-two-images-in-c-net"]C# can do the same thing with the standard library[/URL], but you will have write to a bit more code. The situation with Java and C++ is most likely similar.
[QUOTE=prooboo;40028759]Thanks! I fixed it by putting: /code[/QUOTE] Make sure you set audiocheck1 as true when you need to play the sound, otherwise this code would only play it once.
I just started fiddling with OpenTK and I want to know: is this normal? [IMG]http://i48.tinypic.com/1fzjwm.png[/IMG] The cube is visible from both inside and out. My code is pretty much exactly the same as the 'QuickStart' example code, except I'm drawing a cube, not a triangle. How do I control this effect?
[QUOTE=Nevec;40034846]I just started fiddling with OpenTK and I want to know: is this normal? [IMG]http://i48.tinypic.com/1fzjwm.png[/IMG] The cube is visible from both inside and out. My code is pretty much exactly the same as the 'QuickStart' example code, except I'm drawing a cube, not a triangle. How do I control this effect?[/QUOTE] You want to turn on backface culling, by the looks of it. I'm not sure exactly how OpenTK works, but the OpenGL functionality you want is glEnable(GL_CULL_FACE).
[QUOTE=Chris220;40035053]You want to turn on backface culling, by the looks of it. I'm not sure exactly how OpenTK works, but the OpenGL functionality you want is glEnable(GL_CULL_FACE).[/QUOTE] OpenTK is just a thin wrapper around OpenGL. The equivalent call should be: GL.Enable(EnableCap.CullFace);
[QUOTE=Chris220;40035053]You want to turn on backface culling, by the looks of it. I'm not sure exactly how OpenTK works, but the OpenGL functionality you want is glEnable(GL_CULL_FACE).[/QUOTE] [QUOTE=robmaister12;40035179]OpenTK is just a thin wrapper around OpenGL. The equivalent call should be: GL.Enable(EnableCap.CullFace);[/QUOTE] That seems to have worked. Thank you!
Got a strange C++ problem that I haven't been able to fix. I've got this struct in a header file: [code] // Bounding box variables. struct AABB { float xMax, xMin, yMax, yMin; bool up; bool collision; } BoundingBox; AABB playerBB; [/code] In the .cpp file, I assign "0" to xMax, xMin, yMax and yMin in the constructor. [code] playerBB.xMax = 0; playerBB.xMin = 0; playerBB.yMax = 0; playerBB.yMin = 0; [/code] When I run it, xMax, xMin and yMax are all set to 0, yMin doesn't have any value. I tried other numbers. If I run this code: [code] playerBB.xMax = 800; playerBB.xMin = 0; playerBB.yMax = 800; playerBB.yMin = 720; [/code] Result: xMax = 0, xMin = 800, yMax = 720, yMin = ???. It's like they're all being shifted up one. I can't figure out why it's doing this. Anyone have any ideas?
[QUOTE=st_nick5;40036348]Got a strange C++ problem that I haven't been able to fix. I've got this struct in a header file: [code] // Bounding box variables. struct AABB { float xMax, xMin, yMax, yMin; bool up; bool collision; } BoundingBox; AABB playerBB; [/code] In the .cpp file, I assign "0" to xMax, xMin, yMax and yMin in the constructor. [code] playerBB.xMax = 0; playerBB.xMin = 0; playerBB.yMax = 0; playerBB.yMin = 0; [/code] When I run it, xMax, xMin and yMax are all set to 0, yMin doesn't have any value. I tried other numbers. If I run this code: [code] playerBB.xMax = 800; playerBB.xMin = 0; playerBB.yMax = 800; playerBB.yMin = 720; [/code] Result: xMax = 0, xMin = 800, yMax = 720, yMin = ???. It's like they're all being shifted up one. I can't figure out why it's doing this. Anyone have any ideas?[/QUOTE] Does the same apply to BoundingBox? I would just start ripping out members (like the bools) and see if anything changes.
[QUOTE=Rayjingstorm;40036645]Does the same apply to BoundingBox? I would just start ripping out members (like the bools) and see if anything changes.[/QUOTE] The same applied to BoundingBox. I deleted the AABB playerBB; line, and created a new struct without the bools, and called that playerBB. Both structs work perfectly now. Don't know why it didn't work, but nevermind. Working now.
I have a c# question: Why doesn't this work? List<IQuad> walls = new List<ConcreteQuad>(); Where the latter inherits from the former. I want to upcast my list of quads so it can draw textured and solid colored quads, but I'm not sure how to proceed.
[QUOTE=DoctorSalt;40039793]I have a c# question: Why doesn't this work? List<IQuad> walls = new List<ConcreteQuad>(); Where the latter inherits from the former. I'd have thought downcasting would've worked here, but maybe I have to mess with type constraints or something?[/QUOTE] I'm pretty sure the <> specify what kind of objects the list will hold, so they have to match. I'm also pretty sure you can simply do IQuad wall = new ConcreteQuad(); and put them in the list still. I could also be very wrong about all this.
[QUOTE=mobrockers2;40039923]I'm pretty sure the <> specify what kind of objects the list will hold, so they have to match. I'm also pretty sure you can simply do IQuad wall = new ConcreteQuad(); and put them in the list still. I could also be very wrong about all this.[/QUOTE] I think I'm thinking in line with Java's generic wildcard generics. I'll try that though, upcast individual elements and put them in a list<IBase>. Thanks
[QUOTE=DoctorSalt;40039983]I think I'm thinking in line with Java's generic wildcard generics. I'll try that though, upcast individual elements and put them in a list<IBase>. Thanks[/QUOTE] It's absolutely the same as Java's generics, with the exception that in C# the generic type is preserved at runtime. The reason you can't cast List<Derived> to List<Base> is that you could otherwise try to add Base instances to the List<Derived> which is illegal but impossible to check statically if the cast exists. Edit: If you absolutely must cast a List, you can do this quickly but not with perfect efficiency with listDerivedInstance.Cast<Base>().ToList() . This typecasts every item in the list and returns a new List<Base> instance with the items from listDerivedInstance. The downside is that it's obviously slower than just a cast and creates two enumerator instances, so using List<Base> is better if you want to use that type anyway.
Does anyone have a resource to recommend for someone completely new to game networking? I am in the process of writing a card game in python, and I plan on it being completely network based, but I have no idea how to write the sever and/or client code. The main client is slotted to be Qt4 right now, but for practice I might write a curses and/or html based client (especially considering how simple the UI is) so I'm not sure if I should use the Qt network library or not. If there is a better stepping stone to game networking than a card game I am open to any suggestion, but it would be nice if it were in python.
[QUOTE=Rayjingstorm;40040764]Does anyone have a resource to recommend for someone completely new to game networking? I am in the process of writing a card game in python, and I plan on it being completely network based, but I have no idea how to write the sever and/or client code. The main client is slotted to be Qt4 right now, but for practice I might write a curses and/or html based client (especially considering how simple the UI is) so I'm not sure if I should use the Qt network library or not. If there is a better stepping stone to game networking than a card game I am open to any suggestion, but it would be nice if it were in python.[/QUOTE] Game networking is a very wide topic. For a card game it's enough to just send instructions back and forth and do a little validation so the clients don't cheat. You can do this with a simple TCP connection and push messages over the line that are somehow separable. Some games are good when they run in lockstep, I think Starcraft II does this. Some fighting games use a system that recomputes frames when instructions from a different computer arrive afaik. Networking for action games that require very low latency and can't keep everything completely synchronized is entirely different, the server usually has to use prediction and validate a lot of data. For your card game, the simplest (best) way is likely a TCP connection, but you can also implement messages as HTTP requests instead. If you want to use HTTP it's a lot like writing a website and there should be libraries that handle the connection layer.
[QUOTE=Tamschi;40040955]Game networking is a very wide topic. For a card game it's enough to just send instructions back and forth and do a little validation so the clients don't cheat. You can do this with a simple TCP connection and push messages over the line that are somehow separable. Some games are good when they run in lockstep, I think Starcraft II does this. Some fighting games use a system that recomputes frames when instructions from a different computer arrive afaik. Networking for action games that require very low latency and can't keep everything completely synchronized is entirely different, the server usually has to use prediction and validate a lot of data. For your card game, the simplest (best) way is likely a TCP connection, but you can also implement messages as HTTP requests instead. If you want to use HTTP it's a lot like writing a website and there should be libraries that handle the connection layer.[/QUOTE] So just the python socket library should be enough? Would you recommend I just have a separate Server and Client class and then just keep a "full" game including a server and both clients on the server side, and then just an instance of the Client class on each client's end? Then it would just be keeping the clients up to date through the server which would make sure they aren't breaking any rules or getting information they aren't entitled to.
I'm trying to rotate a cube with 90 degree increments (From arrowkeys, only pitch and yaw) using the following code (XNA): [code] _basicEffect.World = Matrix.CreateFromYawPitchRoll(MathHelper.ToRadians(_xRot), MathHelper.ToRadians(_yRot), 0); [/code] (Here's the full compiled XNA Program: [url]https://dl.dropbox.com/u/8385549/RotatingCube.exe[/url]) Now when just going left/right it works perfectly. but as soon as you press up once you turned away from the starting point the cube will act completely different, and when you pitch 180 degrees, left/right becomes inverted. I'm guessing this has something to do with the rotation being dependend on the previous one, but i can't seem to figure it out.
I'm doing Visual Basic at college, and we're making a program to make booking reservations for cinemas tickets. So my problem is, if they choose to pay by card, they have to pay a charge of £2.00, and if they choose to have the tickets delivered, there is a 50 pence extra charge on top of that. I've got my program displaying the additional price on top of the ticket price if they choose either card or delivery, but as soon as I choose both, they only show one of the values rather than adding them both together, which is what I need my program to do. Our lecturer wants us to be able to figure this out ourselves, most of the class did it in the method of using one combo box, but I find that to be a 'cheating' way of doing it. So any help would be most appreciative. The code I am using to do this calculation is here [CODE]Private Sub cboPayment_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cboPayment.SelectedIndexChanged 'checks to see if the item from the payment box is the card option If cboPayment.SelectedItem = "Card" Then 'The textbox that displays the total price on the reciept form is however much the total ticket prices added together are, plus the extra charge from the card txtRTotal.Text = Format(ticketPrice + card, "c") 'Checks to see if both the card and delivery options are selected ElseIf cboPayment.SelectedItem = "Cash" And cboDelivery.SelectedItem = "Delivery" Then 'The textbox that displays the total price on the reciept form is however much the total ticket prices added together are, plus the total of both the card cost and the delivery cost txtRTotal.Text = Format(ticketPrice + payment, "c") 'if none of the above are true then it is simply the cost of the total ticket prices Else : txtRTotal.Text = Format(ticketPrice, "c") End If End Sub[/CODE] So I put into the event changed of the combo box, so it updates the total each time the value is changed.
[QUOTE=Skidmarks;40044090]I'm doing Visual Basic at college, and we're making a program to make booking reservations for cinemas tickets. So my problem is, if they choose to pay by card, they have to pay a charge of £2.00, and if they choose to have the tickets delivered, there is a 50 pence extra charge on top of that. I've got my program displaying the additional price on top of the ticket price if they choose either card or delivery, but as soon as I choose both, they only show one of the values rather than adding them both together, which is what I need my program to do. Our lecturer wants us to be able to figure this out ourselves, most of the class did it in the method of using one combo box, but I find that to be a 'cheating' way of doing it. So any help would be most appreciative. The code I am using to do this calculation is here [CODE]Private Sub cboPayment_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cboPayment.SelectedIndexChanged 'checks to see if the item from the payment box is the card option If cboPayment.SelectedItem = "Card" Then 'The textbox that displays the total price on the reciept form is however much the total ticket prices added together are, plus the extra charge from the card txtRTotal.Text = Format(ticketPrice + card, "c") 'Checks to see if both the card and delivery options are selected ElseIf cboPayment.SelectedItem = "Cash" And cboDelivery.SelectedItem = "Delivery" Then 'The textbox that displays the total price on the reciept form is however much the total ticket prices added together are, plus the total of both the card cost and the delivery cost txtRTotal.Text = Format(ticketPrice + payment, "c") 'if none of the above are true then it is simply the cost of the total ticket prices Else : txtRTotal.Text = Format(ticketPrice, "c") End If End Sub[/CODE] So I put into the event changed of the combo box, so it updates the total each time the value is changed.[/QUOTE] Something like this [code]Private Sub cboPayment_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cboPayment.SelectedIndexChanged Dim extraPrice As Integer = 0 If cboPayment.SelectedItem = "Card" Then extraPrice = extraPrice + card End If If cboDelivery.SelectedItem = "Delivery" Then extraPrice = extraPrice + payment End If txtRTotal.Text = Format(ticketPrice + extraPrice, "c") End Sub[/code]
[QUOTE=Skidmarks;40044090]I'm doing Visual Basic at college, and we're making a program to make booking reservations for cinemas tickets. So my problem is, if they choose to pay by card, they have to pay a charge of £2.00, and if they choose to have the tickets delivered, there is a 50 pence extra charge on top of that. I've got my program displaying the additional price on top of the ticket price if they choose either card or delivery, but as soon as I choose both, they only show one of the values rather than adding them both together, which is what I need my program to do. Our lecturer wants us to be able to figure this out ourselves, most of the class did it in the method of using one combo box, but I find that to be a 'cheating' way of doing it. So any help would be most appreciative. The code I am using to do this calculation is here /CODE] So I put into the event changed of the combo box, so it updates the total each time the value is changed.[/QUOTE] I'm not familiar with VB but I'd guess your variable 'payment' is not "card + delivery", but rather just one of them. [QUOTE=Goz3rr;40044162]Something like this /code][/QUOTE] Yea this will probably do the trick.
[QUOTE=Goz3rr;40044162]Something like this [code]Private Sub cboPayment_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cboPayment.SelectedIndexChanged Dim extraPrice As Integer = 0 If cboPayment.SelectedItem = "Card" Then extraPrice = extraPrice + card End If If cboDelivery.SelectedItem = "Delivery" Then extraPrice = extraPrice + payment End If txtRTotal.Text = Format(ticketPrice + extraPrice, "c") End Sub[/code][/QUOTE] Sorry, I'm struggling here a little, extraPrice is a variable that has the value of 0, which then becomes 2, if Card is true, but if delivery is true, it becomes 2.5? card = 2 delivery = 0.5 payment = card + delivery Edit: Nevermind, I sorted it, I followed your example code too much rather than reading it and seeing how I could add it to my existing code. [CODE]Private Sub cboPayment_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cboPayment.SelectedIndexChanged 'extraPrice is a variable that stores the values of card and delivery and checks if they are selected in the form, thank you Goz3rr. Dim extraPrice As Decimal 'If the option card is selected, then the extraPrice is whatever the previous value of extraPrice was, plus 2 If cboPayment.SelectedItem = "Card" Then extraPrice = extraPrice + card End If 'if the option Delivery is selected, then the extra price is whatever the previous value of extraPrice was, plus 0.5 If cboDelivery.SelectedItem = "Delivery" Then extraPrice = extraPrice + delivery End If 'the textbox that contains the total price is the total price of the tickets plus the extraPrice txtRTotal.Text = Format(ticketPrice + extraPrice, "c") End Sub[/CODE] Thank you very much for your help.
I'm trying to work out the time a car will take to travel down a straight road of a certain length, with a certain required start and end speed, and a certain possible acceleration and deceleration and a certain top speed. It should be a simple problem but I can't get my head around it. At the moment I'm doing it like this: [code] u=start_speed v=top_speed time_acc = (v-u)/acceleration length_acc = (sqr(v) - sqr(u))/(2*acceleration) u=v v=end_speed time_dec = (v - u)/deceleration length_dec = (sqr(v) - sqr(u))/(2*deceleration) length_constant = total_length - length_acc - length_dec time_constant = length_constant/spd[i,0] time = time_constant + time_acc + time_dec [/code] It basically calculates the time it takes to accelerate up to full speed, the time it cruises for, and then the time it decelerates for. This works great, until it is no longer possible for the car to accelerate to the top speed then decelerate to the required speed in the length of road given. In that situation it (obviously) goes screwy, but I can't work out how to change it so I can calculate it even if the car can't reach it's top speed in time and has to start to brake before it accelerates up to top speed. Any ideas?
[QUOTE=Goz3rr;40043642]I'm trying to rotate a cube with 90 degree increments (From arrowkeys, only pitch and yaw) using the following code (XNA): [code] _basicEffect.World = Matrix.CreateFromYawPitchRoll(MathHelper.ToRadians(_xRot), MathHelper.ToRadians(_yRot), 0); [/code] (Here's the full compiled XNA Program: [URL]https://dl.dropbox.com/u/8385549/RotatingCube.exe[/URL]) Now when just going left/right it works perfectly. but as soon as you press up once you turned away from the starting point the cube will act completely different, and when you pitch 180 degrees, left/right becomes inverted. I'm guessing this has something to do with the rotation being dependend on the previous one, but i can't seem to figure it out.[/QUOTE] It's a problem with euler angles, the workaround is most likely somewhat complicated. (Euler angles suffer from gimbal lock, so the answer to your problem is probably a discontinuous function.) If you have the option to switch to quaternions do that, then you can just store one rotation for your cube and increment it based on the pressed keys. [URL="http://www.iquilezles.org/www/articles/quaternions/quaternions.htm"]Quaternions represent rotations as four values[/URL], if you multiply them the rotations are added commutatively.
How would I create random points within a circle with a diameter of 10 or a radius of 5 with a center point of (x,y)
[QUOTE=jaooe;40058910]How would I create random points within a circle with a diameter of 10 or a radius of 5 with a center point of (x,y)[/QUOTE] One way would be to generate two random numbers (a and b) on [x - 5, x + 5] and [y - 5, y + 5] respectively, and then check if a[sup]2[/sup] + b[sup]2[/sup] <= 25. That might be a little slow to check, but it's a good method. Another way would be to increase an angle, t, however many times you want, and choose a single random number n from [0, 5]. (x + n*cos(t), y + n*sin(t)) would be a random point on the line that makes an angle t from the horizontal. I guess this isn't truly random, because the range of points possible depends on what value you increase t by.
[QUOTE=account;40059201]One way would be to generate two random numbers (a and b) on [x - 5, x + 5] and [y - 5, y + 5] respectively, and then check if a[sup]2[/sup] + b[sup]2[/sup] <= 25. That might be a little slow to check, but it's a good method. Another way would be to increase an angle, t, however many times you want, and choose a single random number n from [0, 5]. (n*cos(t), n*sin(t)) would be a random point on the line that makes an angle t from the horizontal. I guess this isn't truly random, because the range of points possible depends on what value you increase t by.[/QUOTE] Cheers. :smile:
[QUOTE=Tamschi;40055358]It's a problem with euler angles, the workaround is most likely somewhat complicated. (Euler angles suffer from gimbal lock, so the answer to your problem is probably a discontinuous function.) If you have the option to switch to quaternions do that, then you can just store one rotation for your cube and increment it based on the pressed keys. [URL="http://www.iquilezles.org/www/articles/quaternions/quaternions.htm"]Quaternions represent rotations as four values[/URL], if you multiply them the rotations are added commutatively.[/QUOTE] I tried this, although this probably isn't how you use quats: [code]Quaternion qX = Quaternion.CreateFromAxisAngle(Vector3.Up, MathHelper.ToRadians(_xRot)); Quaternion qY = Quaternion.CreateFromAxisAngle(Vector3.Left, MathHelper.ToRadians(_yRot)); _basicEffect.World = Matrix.CreateFromQuaternion(qX) * Matrix.CreateFromQuaternion(qY);[/code] I don't think it's gimbal lock though. The problem is, i think that by transforming the matrix the axises also change, because while everything looks fine at the default angle, when you rotate the yaw by 90 degrees, pitch will still be the same movement, except it will look wrong since the camera position doesn't change, if that makes any sense
Trying to calculate the vectorat the end of a line in Lua. This is basically what I am doing. [CODE] x2 = (length * math.cos(angle)) + x1 y2 = (length * math.sin(angle)) + y1 [/CODE] All of the variables are correct(I triple checked) and the angle is in degrees, so it is either my formula or Lua. I was thinking that it could be because the Y axis is flipped but x2 isn't right either.
A quick google search finds that math.cos and math.sin take radians, not degrees.
Sorry, you need to Log In to post a reply to this thread.