• What Do You Need Help With? V6
    7,544 replies, posted
While you have my sympathy, this thread is meant for coding-specific help. It's not easy giving advice to find motivation, since I imagine it differs from person to person and situation to situation. Perhaps try tea and good music.
[QUOTE=ZeekyHBomb;40504769]Perhaps try tea and good music.[/QUOTE] I have this thing where I listen to the same song over and over until I'm done with my writing/coding session. 4 hours of the 11th Doctor's theme. I'm weird.
[QUOTE=ZeekyHBomb;40499182]You apparently have to compile lwjgl to a native library as well, via [code]$ gcj -c -fjni lwjgl.jar $ gcj -o liblwjgl_native.so -fjni -Wl liblwjgl.so lwjgl.o[/code] And you have to compile your project with -fjni as well and link to liblwjgl_native.so (-Wl liblwjgl_native.so).[/QUOTE] Can't even do: [code]$ gcj -c -fjni lwjgl.jar[/code] without the terminal spewing trash, even in the folder lwjgl.jar is located at.
I am working on a project that takes in an exe and an input file. The program grades another exe file, and the input file tells it what to grade. I got everything to work with a single form, but when there is multiple forms, it seems to have issues determining which form to use. I narrowed it down to a method, that causes an exception. Public Sub InvokeMethod(ByVal form As Form, ByVal methodName As String, ByVal parms As Object()) Dim eh As EventHandler = System.Delegate.CreateDelegate(GetType(EventHandler), form, methodName) If eh <> Nothing Then form.Invoke(eh, parms) End If End Sub "Dim eh As EventHandler = ...." causes an exception, " Error binding to target method." Do you guys have any idea how to fix this?
I know a small amount of Python and I'm sort of wanting to learn C, do you think it would be worth the effort or should I just improve on my Python. Thank you.
[QUOTE=Stonecycle;40508641]Can't even do: [code]$ gcj -c -fjni lwjgl.jar[/code] without the terminal spewing trash, even in the folder lwjgl.jar is located at.[/QUOTE] GCJ only seems to support most of Java 1.4 and some of 1.5. Perhaps LWJGL was written on basis of a newer language revision? I don't really know GCJ though.. [editline]3rd May 2013[/editline] [QUOTE=Leestons;40510313]I know a small amount of Python and I'm sort of wanting to learn C, do you think it would be worth the effort or should I just improve on my Python. Thank you.[/QUOTE] Learning a new language, even just taking a few steps in it, is (almost) always a huge learning opportunity in several ways. You get a better picture of what languages and paradigms are out there, you learn which tool is best for which job and you can learn to approach problems in different ways. Be careful to not carry over idioms from one to another language though! Features might look the same, but behave differently (perhaps even subtly so) or the language could provide a better way of dealing with an issue (for example you'll see no exceptions in C, that's usually done by returning error-code and in some libraries via callback).
I'm at a point where I have to do server-side entity management. I'm looking for an abstract explanation of a good approach. I want to make my client-side as cheat-free as possible. My first thought was, that I'd have entity classes on the server side, e.g. Enemy, which holds a position, a speed, attack speed, etc. And I'd write into the client-side API a Instantiate function, which would put everything in a server-side hashtable. The most important thing is that the each Entity should be able to get information from other entities. For example, the enemy needs to know the player position. I could theoretically loop through the table to find whatever I need, and send it to whoever wants it. What would be a good approach to this?
I started tinkering with Android a few days ago, coming from no experience with Java at all. I'm trying to play with multi-touch and all seems fine until I release the first pointer. Then the second, third, fourth, etc.. shift places. How do I correct this? Here is my code thus far: [url]http://pastebin.com/chjt8cbz[/url]
[QUOTE=false prophet;40513941]I started tinkering with Android a few days ago, coming from no experience with Java at all. I'm trying to play with multi-touch and all seems fine until I release the first pointer. Then the second, third, fourth, etc.. shift places. How do I correct this? Here is my code thus far: [url]http://pastebin.com/chjt8cbz[/url][/QUOTE] You need to infer each frame which current pointer is which one from the last frame based on distance.
[QUOTE=Asgard;40512161]I'm at a point where I have to do server-side entity management. I'm looking for an abstract explanation of a good approach. I want to make my client-side as cheat-free as possible. My first thought was, that I'd have entity classes on the server side, e.g. Enemy, which holds a position, a speed, attack speed, etc. And I'd write into the client-side API a Instantiate function, which would put everything in a server-side hashtable. The most important thing is that the each Entity should be able to get information from other entities. For example, the enemy needs to know the player position. I could theoretically loop through the table to find whatever I need, and send it to whoever wants it. What would be a good approach to this?[/QUOTE] What is the best approach depends on many factors, having a lot of the stuff server side while making it harder to cheat can also drastically increase the bandwidth requirements both for the client and server, the best thing to do is to find a balance between security and performance. Regardless of the methods you use to obfuscate the client / server communication if your game is popular someone is going to eventually crack it so you should strongly consider if it's really worth the effort.
More c++ questions. I'm trying to create a linked list in alphabetical order and I'm not entirely sure where to start. I need an exception for if the list is totally empty (just throw the first node in there), but other than that I'm not sure what to do. The way I want to do it is to make the new node, then check where it needs to go, then handle that appropriately. so i'm thinking it'd look roughly like this: [cpp] //Input file looks like this: //Last name, first name //Gender Age // //Ex: Johnson, Jim // M 83 //Variables PersonNode* perPtr; PersonNode* searchPtr; //Search through list to check alphabetical order //Initialize perPtr = head; //Head will be passed through when this is called searchPtr = head; //This will be all inFile, so I'll just write it like that I guess while(inFile) { //Create new node perPtr = new PersonNode; getline(inFile, perPtr -> name); inFile.ignore(100,'\n'); inFile.get(perPtr -> gender); inFile.ignore(100,' '); inFile >> perPtr -> age; if(head = NULL) //Nothing in list { //Add to front } else if(head -> next = NULL) //One item in list { //If searchPtr -> name is alphabetically greater than the new node (ie A > B), adds behind searchPtr. Else adds in front. if(searchPtr -> name > perPtr -> name) { //Add to tail } else { //Add to head } } else { //Insert appropriately } perPtr -> next = head; head = perPtr; } return head;[/cpp] I'm not sure if there's a way to make that more efficient, though. I mean this seems like the smartest way to handle it, but I'm not sure if I'm missing something. [editline]3rd May 2013[/editline] also checking if(head -> next = NULL) seems like a questionable check. I know it'll work, but I don't like checking head -> next. Might just be me, though. Also I have a feeling I'll need to track the tail, too. I'll have to do that SOMEWHERE. Probably after else if(head -> next = NULL)
-Snip-
[QUOTE=ZeekyHBomb;40511800] [editline]3rd May 2013[/editline] Learning a new language, even just taking a few steps in it, is (almost) always a huge learning opportunity in several ways. You get a better picture of what languages and paradigms are out there, you learn which tool is best for which job and you can learn to approach problems in different ways. Be careful to not carry over idioms from one to another language though! Features might look the same, but behave differently (perhaps even subtly so) or the language could provide a better way of dealing with an issue (for example you'll see no exceptions in C, that's usually done by returning error-code and in some libraries via callback).[/QUOTE] Thanks for the response, ZeekyHBomb. Much appreciated. I think I'll look into learning C soon even if it's just for the learning experience.
where can I get some old retro type sound effects, like from an old 8 bit game. specifically gun shots and background music
That doesn't really belong here, apparently this is just for programming and coding and shit. That being said, back when I was trying (and failing) to be good at flash, I used [URL="http://www.flashkit.com/soundfx/"]FlashKit[/URL].
[QUOTE=Zinayzen;40519614]More c++ questions. I'm trying to create a linked list in alphabetical order and I'm not entirely sure where to start. I need an exception for if the list is totally empty (just throw the first node in there), but other than that I'm not sure what to do. The way I want to do it is to make the new node, then check where it needs to go, then handle that appropriately. so i'm thinking it'd look roughly like this: [cpp]//code[/cpp] I'm not sure if there's a way to make that more efficient, though. I mean this seems like the smartest way to handle it, but I'm not sure if I'm missing something. [editline]3rd May 2013[/editline] also checking if(head -> next = NULL) seems like a questionable check. I know it'll work, but I don't like checking head -> next. Might just be me, though. Also I have a feeling I'll need to track the tail, too. I'll have to do that SOMEWHERE. Probably after else if(head -> next = NULL)[/QUOTE] Is this another assignment? Your teacher doesn't seem to do his/her job very well! You don't need a special case for a list with a single element. And you're doing something weird at the end of the loop-body. It's probably best to handle this inside the conditional branches. The 'normal' case will be inserting to a list with a couple of elements. The way I'd do that is find the element right before where the new item belongs to. Then you can just do iter->next = new Node(item, iter->next);. This handles the edge-case, where we want to append to the last element, just fine. The two other edge-cases are there is no element yet, so I'd do that just like you are already doing, and that we have to prepend to the first element. For that case I'd just compare the head-item with the item to insert first, to see if we have to prepend, and otherwise enter the normal case, which handles the event that the new item belongs just after the head-element fine. Also, are you required to store the tail of the list? If not, you probably won't need it.
[QUOTE=DesolateGrun;40520753]where can I get some old retro type sound effects, like from an old 8 bit game. specifically gun shots and background music[/QUOTE] Maybe not too helpful but retro style sound effects are very easy to make with [url=http://www.milkytracker.org/]MilkyTracker[/url], you can even make some good music if you put a little effort in.
It's not that he doesn't teach well, I just didn't pay attention and he didn't go into specific details about this. Come to think of it I might not need to store the tail at all, I'm never adding directly to the tail. This is the only part of the assignment I'm having an issue with, every other function works fine. I've just been putting this one off. :v:
more rookie help I used a loop and a key stroke in order to fire a gun in my little game, but if you press or hold the key really fast you can fire the gun too many times, how can I make it limited to fire once every 2 seconds? Loop for firing [code] public void actionPerformed(ActionEvent e) { ArrayList ms = craft.getMissiles(); for (int i = 0; i < ms.size(); i++) { Gun1 m = (Gun1) ms.get(i); if (m.isVisible()) m.move(); else ms.remove(i); } [/code] keystroke [code] public void fire() { missiles.add(new Gun1(x + CRAFT_SIZE, y + CRAFT_SIZE/2)); } public void keyPressed(KeyEvent e) { int key = e.getKeyCode(); if (key == KeyEvent.VK_INSERT) { fire(); }[/code] [t]http://i40.tinypic.com/34e9i04.png[/t] what it looks like if anyone was wondering
is that a pong shooter?
[QUOTE=Zinayzen;40525911]is that a pong shooter?[/QUOTE] I wanted to make it really arcadey since the art is really simple, that solid bar isnt the ppong paddle though.
[QUOTE=DesolateGrun;40525637]more rookie help I used a loop and a key stroke in order to fire a gun in my little game, but if you press or hold the key really fast you can fire the gun too many times, how can I make it limited to fire once every 2 seconds? Loop for firing [code] public void actionPerformed(ActionEvent e) { ArrayList ms = craft.getMissiles(); for (int i = 0; i < ms.size(); i++) { Gun1 m = (Gun1) ms.get(i); if (m.isVisible()) m.move(); else ms.remove(i); } [/code] keystroke [code] public void fire() { missiles.add(new Gun1(x + CRAFT_SIZE, y + CRAFT_SIZE/2)); } public void keyPressed(KeyEvent e) { int key = e.getKeyCode(); if (key == KeyEvent.VK_INSERT) { fire(); }[/code] [t]http://i40.tinypic.com/34e9i04.png[/t] what it looks like if anyone was wondering[/QUOTE] Could use a thread, set the thread to sleep for 2 seconds after firing, might be a bit overkill for such a small task. Or you could use either a swing or util timer. I find the swing timer to be easier for such small things.
[QUOTE=DesolateGrun;40526014]I wanted to make it really arcadey since the art is really simple, that solid bar isnt the ppong paddle though.[/QUOTE] That board looks almost identical to a pong board. Sort of. I mean there are two lines instead of one. Looks good, though. Very retro. Also I can't fucking get this one part to work and it's driving me insane. [cpp] if(!(cin >> commandCheck)) { invalid = true; cin.ignore(1000,'\n'); cin.clear(); cout << "**** Please input a NUMBER between " << menuMin; cout << " and " << menuMax << "****" << endl; }[/cpp] That's inside a loop. It SHOULD prevent character input where I require int inputs, but for some reason that check doesn't register and it goes into a loop if I put in like 'x' instead of 0-6. [editline]4th May 2013[/editline] nevermind i'm an idiot, clear and ignore were in the wrong order also swapped that 1000 to the streamsize_max() command or whatever it is. Looks better that way.
[QUOTE=Zinayzen;40527194]That board looks almost identical to a pong board. Sort of. I mean there are two lines instead of one. Looks good, though. Very retro. Also I can't fucking get this one part to work and it's driving me insane. [cpp] if(!(cin >> commandCheck)) { invalid = true; cin.ignore(1000,'\n'); cin.clear(); cout << "**** Please input a NUMBER between " << menuMin; cout << " and " << menuMax << "****" << endl; }[/cpp] That's inside a loop. It SHOULD prevent character input where I require int inputs, but for some reason that check doesn't register and it goes into a loop if I put in like 'x' instead of 0-6. [editline]4th May 2013[/editline] nevermind i'm an idiot, clear and ignore were in the wrong order also swapped that 1000 to the streamsize_max() command or whatever it is. Looks better that way.[/QUOTE] yeah I realized that afterwards so i did the two lines instead of one, i just recolored the commodore 64 screen and made it bigger
Ok so, I think i'm derping massively here. But over multiple classes and even within the same classes what are the protection rules for variables, etc? For example, in this piece of code, how would I make it secure but so that in the AddWeapon method I can access the list? [code]static class Player { int Health = 100; int Armor = 0; List<Weapon> Weapons = new List<Weapon>(); public static void AddWeapon(string _Name, int _Damage, int _Rate) { // access the weapons list here } }[/code]
[QUOTE=JakeAM;40529675]Ok so, I think i'm derping massively here. But over multiple classes and even within the same classes what are the protection rules for variables, etc? For example, in this piece of code, how would I make it secure but so that in the AddWeapon method I can access the list? [code]static class Player { int Health = 100; int Armor = 0; List<Weapon> Weapons = new List<Weapon>(); public static void AddWeapon(string _Name, int _Damage, int _Rate) { // access the weapons list here } }[/code][/QUOTE] Public means no scope restriction, protected means package scope, private means class scope.
[QUOTE=mobrockers2;40529703]Public means no scope restriction, protected means package scope, private means class scope.[/QUOTE] Ok, so how come if I make the list public I can't access it from the method?
Also why are you declaring the class and method static? That class doesn't look like you'd want to access it statically. [editline]5th May 2013[/editline] [QUOTE=JakeAM;40529734]Ok, so how come if I make the list public I can't access it from the method?[/QUOTE] You can't restrict access to a global within a class, those keywords only have meaning outside of this class. Looks like you might be getting a non-static reference warning?
Ok so I changed it from being static. But I now have the problem of not being able to access the enum from the player class. [code]using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Test { class Program { static void Main(string[] args) { Player player = new Player(); } } class Weapon { string Name; int Damage; speed Rate; public enum speed { VERY_SLOW, SLOW, FAST, VERY_FAST }; void Weapon(string _Name, int _Damage, speed _Rate) { Name = _Name; Damage = _Damage; Rate = _Rate; } } class Player { int Health = 100; int Armor = 0; List<Weapon> Weapons = new List<Weapon>(); public void AddWeapon(string _Name, int _Damage, speed _Rate) { Weapons.Add(_Name, _Damage, _Rate); } } }[/code]
[url]http://www.csharp-station.com/tutorials/lesson19.aspx[/url]
Sorry, you need to Log In to post a reply to this thread.