• What do you need help with? V. 3.0
    4,884 replies, posted
Is there any limit on how many mouse buttons xlibs xbuttonevent can handle? Would be handy to know.
[QUOTE=dvondrake;33578221]Not so much a technical question as just asking for opinions, but what does everyone think about SDL vs SFML? I can't decide which I want to use for my rendering engine, and I'm seeing lots of completely mixed reviews. SFML does seem easier to use though.[/QUOTE] SDL: - C-Style library - Renders graphics with CPU - Runs on many platforms SFML: - A modernized C++ library & object oriented - Uses OpenGL to render (known to be faster than SDL in most cases) - Much more functions available (More graphics capabilities and has a networking class) - Cross-platform on PCs (I have never seen SFML used on devices or the sort)
[QUOTE=ief014;33578395]SDL: - C-Style library - Renders graphics with CPU - Runs on many platforms SFML: - A modernized C++ library & object oriented - Uses OpenGL to render (known to be faster than SDL in most cases) - Much more functions available (More graphics capabilities and has a networking class) - Cross-platform on PCs (I have never seen SFML used on devices or the sort)[/QUOTE] SDL can use OpenGL to speed things up, but things are done more manually. I'd use SFML, but it's broken for me.
I'd like a way to get terminal input from the user and also display output without this conflicting. The standard stdio\stdin stuff won't work, because as soon as you output something it'll have been put in the middle of whatever the user was typing. I know the answer to this is "use curses" but I'm having some difficulty finding exactly how. I thought I'd use the curses Window system and make a window for output and a one-line window for input... but then I got stuck trying to figure how how to fix the windows whenever the user decides to be a dick and resize the terminal. Any thoughts?
Heya, I've exported my game into a runnable .jar file, but it's crashing whenever it tries to find the level files in Game.jar/res/maps. It's fine if I put it in my eclipse workspace to run, though. I've gathered I need to define the map files using absolute rather than relative file paths, but how do I do that when I don't know what folder on their computer the user will have the .jar saved in?
[QUOTE=ief014;33578395]SDL: - C-Style library - Renders graphics with CPU - Runs on many platforms SFML: - A modernized C++ library & object oriented - Uses OpenGL to render (known to be faster than SDL in most cases) - Much more functions available (More graphics capabilities and has a networking class) - Cross-platform on PCs (I have never seen SFML used on devices or the sort)[/QUOTE] With SDL 1.3 at least it's not hard to get hardware acceleration. Just a flag when creating the windows and then load the pictures into SDL_Textures instead of SDL_Surfaces. It's true though that you'll have access to less graphical features since SDL wants to be able to use multiple backends (including an I think built-in software renderer). You could use straight OpenGL and use SDL just for managing the window, input 'n stuff, but that'll of course be less easy than using pre-defined abstractions like found in SFML. SDL_net provides networking functions in a SDL-like fashion; never used it myself though.
SDL 1.3 is not in a usable state yet. Mouse grabbing, for example, doesn't work at all.
[QUOTE=Nigey Nige;33579792]Heya, I've exported my game into a runnable .jar file, but it's crashing whenever it tries to find the level files in Game.jar/res/maps. It's fine if I put it in my eclipse workspace to run, though. I've gathered I need to define the map files using absolute rather than relative file paths, but how do I do that when I don't know what folder on their computer the user will have the .jar saved in?[/QUOTE] If you want to load the resources inside the .jar, and they're next to your loading class, then use: [cpp] BufferedInputStream input = (BufferedInputStream) ClassName.class.getResourceAsStream("/path/to/maps/"); [/cpp] If the map files are next to your .jar in the same folder, then use: [cpp] BufferedInputStream input = (BufferedInputStream) ClassName.class.getClassLoader().getResourceAsStream("/path/to/maps/"); [/cpp]
Hi guys, can anyone recommend me a certain C++ library that I can use for plotting things like flight paths (aswell as other graphs). I have looked into Gnuplot, but I am not sure if it's right for me.
I've done plots with [url=http://cairographics.org/]Cairo[/url], but it's more of a general-purpose vector graphics library than a 'plotting' library.
Gah. Can somebody please explain how do I implement GetEnumerator()? I made a class like so: [csharp] public class MessageSet { public List<Message> Messages { get; set; } public string Recipient { get; set; } } [/csharp] Then I have: [csharp] static void OnJoin(object sender, JoinEventArgs e) { MessageSet set = msys.CheckForMessages(e.Who); foreach (Message message in set) { SendMessage(Mst.Channel, message.Text + "|" + message.Setter, e); } } [/csharp] I get this error in the foreach: "foreach statement cannot operate on variables of type 'IRCConsole.MessageSet' because 'IRCConsole.MessageSet' does not contain a public definition for 'GetEnumerator'" I have no cooking clue how to implement it. Thanks in advance.
[QUOTE=Naarkie;33584031]Gah. Can somebody please explain how do I implement GetEnumerator()? I made a class like so:[/QUOTE] Something like this: [csharp] public class MessageSet : public IEnumerable<Message> { public List<Message> Messages { get; set; } public string Recipient { get; set; } public IEnumerator<Message> GetEnumerator() { return Messages.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } } [/csharp]
I have a programming assignment for Java that involves interfaces: [QUOTE]1.Write a class Compare3 that provides a static method largest. Method largest should take 3 Comparable parameters and return the largest of the 3(so its return type will also be Comparable). Recall that method compareTo is part of the Comparable interface, so largest can use the compareTo method of its parameters to compare them.[/QUOTE] The book briefly explains interfaces and only says what they are and how to use them. It doesn't explain how to make sure that the parameters passed are values that implement Comparable. Also, what is it hinting at when it says "largest can use the compareTo method"? I thought you couldn't use the implement keyword when making an interface. EDIT: Just remembered something. If interfaces can't be instanced, then why does it say that largest has to be static? If the interface can't use static for the method, then how do I make sure that it is? Disregard that edit, just realized that it says to make a CLASS called compare3, not an interface
[QUOTE=ROBO_DONUT;33583933]I've done plots with [url=http://cairographics.org/]Cairo[/url], but it's more of a general-purpose vector graphics library than a 'plotting' library.[/QUOTE] Thanks, I will try this for sure. It looks like a nice introduction to it aswell!
[QUOTE=Ehmmett;33587142][lua]for i=1,#boxes do--in all the boxes if not containsPoint(predictedX,predictedY,boxes[i][1],boxes[i][2],boxes[i][3],boxes[i][4]) and inScreen(predictedX,predictedY) then--if not colliding colliding = false--set variable to false else --if we are colliding colliding = true--set variable to true end end --end loop[/lua] Why does this seem to only loop to the very last box. I tried the 'i,k in ipairs(boxes)' thing but that just did the same thing and my player would only collide with the very last box still. It's a part of a function that is called every update too.[/QUOTE] The colliding var gets overwritten by the next iteration of the loop, and so on, so only the last iteration actually takes effect. As a quick solution, you could break out of the loop when a collide check passes or run whatever collision handling code you have there, but there are better methods that'll handle collision with multiple box objects at once better.
If you are trying to find out whether or not the thing collides with any of the boxes, "colliding = collidng || hitting", where hitting is your function that determines the collision for this iteration. If you want to perform an action for every box it collides with, "if hitting then do_stuff() end" If you want to perform an action the first time you detect it collides with anything, "if hitting then return do_stuff() end"
So I've been trying to make a C# program in which users can login (MySQL) and access their account settings. My idea was this: 1. Login form, the first window that pops up prompting for username & password 2. Main form, which is the second form that pops up and has options for updating, adding or removing in the database (all based off of their username, so the variable HAS to be passed onto this form). Seems simple, and it is, but since I'm pretty noob to C# (1 day, in fact, and I'm already creating an application that interfaces with a database) I have some issues (obviously). My only problem at this stage is closing the login form, transferring the username from it and onto the main form. I thought it'd be simple and I've tried many ways but none really effectively work how I pictured. I want the persons username (already in a variable) to go into the main form with all the settings because all of the SQL queries inside of it will be based off of their username. [editline]5th December 2011[/editline] This was the closest I got to fixing my problem, but I can't seem to figure out how to pass the friggin username variable onto the main form: [url]http://stackoverflow.com/questions/4759334/how-can-i-close-a-login-form-and-show-the-main-form-without-my-application-closi[/url]
Are there any good books on/or include networking in C#?
[QUOTE=chimitos;33537973]In java, how would I get strings "1" and "b" from the input "1b"?[/QUOTE]
[QUOTE=chimitos;33593360][/QUOTE] You don't clarify at all what you're splitting by. A perfectly valid response is inputString[0] and inputString[1]. If this isn't what you're looking for, clarify your question. [editline]6th December 2011[/editline] [QUOTE=Floatation;33593136]This was the closest I got to fixing my problem, but I can't seem to figure out how to pass the friggin username variable onto the main form: [url]http://stackoverflow.com/questions/4759334/how-can-i-close-a-login-form-and-show-the-main-form-without-my-application-closi[/url][/QUOTE] Do whatever that says, then make a new constructor in your main form with a single parameter, string userName. You should find a constructor automatically generated, so you can just edit that one if you like.
I got the error "Using the generic type 'System.Collections.Generic.IEnumerator<T>' requires 1 type arguments" on line 14, so I changed it to this: [csharp] public class MessageSet : IEnumerable<Message> { public List<Message> Messages { get; set; } public string Recipient { get; set; } public IEnumerator<Message> GetEnumerator() { return Messages.GetEnumerator(); } IEnumerator<Message> IEnumerable<Message>.GetEnumerator() { return GetEnumerator(); } } [/csharp] But that gives me the error "IRCConsole.MessageSet' does not implement interface member 'System.Collections.IEnumerable.GetEnumerator()'. 'IRCConsole.MessageSet.GetEnumerator()' cannot implement 'System.Collections.IEnumerable.GetEnumerator()' because it does not have the matching return type of 'System.Collections.IEnumerator."
[QUOTE=Naarkie;33593943]I got the error "Using the generic type 'System.Collections.Generic.IEnumerator<T>' requires 1 type arguments" on line 14, so I changed it to this:[/QUOTE] My first way is correct, just tried it myself. You just need to include "using System.Collections".
[QUOTE=raBBish;33594414]My first way is correct, just tried it myself. You just need to include "using System.Collections".[/QUOTE] Dammit, didn't even realise >.< Thanks alot EDIT: So I have another issue. I need to serialise the MessageSet class. This is my code to serialise it: [csharp] public void SerialiseToXML(string recipient, Message message) { MessageSet messageSet = new MessageSet(); messageSet.Messages = new List<Message>() { }; messageSet.Messages.Add(message); messageSet.Recipient = recipient; XmlSerializer serializer = new XmlSerializer(typeof(MessageSet)); TextWriter textWriter = new StreamWriter(messageSet.Recipient + @".xml"); serializer.Serialize(textWriter, messageSet); textWriter.Close(); } [/csharp] What it should be doing is creating an xml file with these contents, for example: [xml] <MessageSet> <Recipient>Naarkie</Recipient> <Messages> <Message> <Setter>Naarkie</Setter> <Text>HOHOHO</Text> <Date>2011-12-06T12:20:06.0634+02:00</Date> <Recipient>Naarkie</Recipient> </Message> </Messages> </MessageSet> [/xml] Instead, it's making a file like this: [xml] <ArrayOfMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Message> <Setter>LOL</Setter> <Text>NUNUNUN</Text> <Date>2011-12-06T12:20:06.0634+02:00</Date> <Recipient>Naarkie</Recipient> </Message> </ArrayOfMessage> [/xml] The Deserialisation method chokes, because it's not how it expects the xml file to be like. (There is an error in XML document (2, 2)) If it makes any difference, the compiler made me add an Add() method to the MessageSet class. I put this there: [csharp] public List<Message> Add(Message m) { Messages.Add(m); return Messages; } [/csharp] I think that's the reason it's failing :/
Getting [url=http://www.amazon.com/gp/product/0596800959?ie=UTF8&tag=cinanu-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0596800959]this.[/url] Opinions?
Quite a big nutshell isn't it, 1058 pages.
*snip, fixed*
I am trying to code a simple game in C# (with xna) that will use a grid/squares. I can't think of a smart solution, anybody that have made something similar? Code is not that needed, what I need is the theoretical part.
[QUOTE=chimitos;33593360]In java, how would I get strings "1" and "b" from the input "1b"?[/QUOTE] substrings or charAt with chars if the string name was s, then [CODE] char subString1 = s.charAt(0); char subStringb = s.charAt(1); [/CODE] I'm not sure how you would do it with substrings since I've never used them, but the [URL="http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#substring(int)"]API[/URL] should help you on them. [editline]6th December 2011[/editline] [QUOTE=IAmAnooB;33595853]I am trying to code a simple game in C# (with xna) that will use a grid/squares. I can't think of a smart solution, anybody that have made something similar? Code is not that needed, what I need is the theoretical part.[/QUOTE] Excuse me if there is a better way, but what I would do is make a multidimensional array with numbers that represented a specific tile. Ie. 1 would be grass, 3 water, etc. Something like [URL="http://love2d.org/wiki/Tutorial:Tile-based_Scrolling"]this[/URL]
So I now got a :v: spewing pellets, how to I make the speed consistent? The further away I point the mouse the faster they go. [code] using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; namespace GungeonCrawl { public class Bullet { MouseState mouse; Texture2D texture; Vector2 position, movedirection; Rectangle rectanglebullet; public void Initialize(Vector2 position, Texture2D texture) { mouse = Mouse.GetState(); this.texture = texture; this.position = position; movedirection.X = position.X - mouse.X; movedirection.Y = position.Y - mouse.Y; movedirection /= 50; } public void Update() { position -= movedirection; rectanglebullet = new Rectangle((int)position.X, (int)position.Y, 5, 5); } public void Draw(SpriteBatch spriteBatch) { spriteBatch.Draw(texture, rectanglebullet, Color.White); } } } [/code] [img]http://i.imgur.com/nH0fD.png[/img]
[QUOTE=Red scout?;33596389]So I now got a :v: spewing pellets, how to I make the speed consistent? The further away I point the mouse the faster they go.[/QUOTE] [csharp]movedirection.X = position.X - mouse.X; movedirection.Y = position.Y - mouse.Y; movedirection.Normalize(); movedirection *= <insert speed here>;[/csharp]
Sorry, you need to Log In to post a reply to this thread.