Computer Science Canada Help with fighting system |
Author: | Talion [ Sun Jan 15, 2006 9:36 am ] | ||
Post subject: | Help with fighting system | ||
Alright i'm trying to make a game here with a fighting system. Now I can make the maps and characters and their stats and such but my battle system wont work. Atm I've scrapped it entirely and now am trying to rebuild it. It's not working though and i've been at it for ages so I've come to ask for some help. The problems I have are that A)you can only attack once with a button before it simply stops working and B) I can't make it so that if you kill the enemy it says they die but if you dont kill them it says it's their turn. (I haven't added in the enemies turn yet though...since i've noticed it says they die no matter what)
So can anyone help me out here? Martin says: Can you please use more descriptive titles in the future? |
Author: | Delos [ Sun Jan 15, 2006 10:07 am ] | ||
Post subject: | |||
Your main problem is that the if structure is based on the direct output of mousewhere(). This is usually not a problem, but since this loop won't take all that long to recurse, a single click will be registered several times over - hence several actions will be taken at one time. Look up Mouse.ButtonMoved() and Mouse.ButtonWait() and incorporate those into it. I tried it and in a good situation, I was able to click several times each producing a different amount of damage dealt. I also got the 'it's enemy's turn' message, so things should be working correctly. However, if I started with the enemy evading my attack, they continually did so, no matter how many times I clicked. You know how to make records, so why not improve on your mouse variables by making a 'mouse' type? While you're at it, 'button1..button7' sounds suspiciously like a series of variables that would be better off as an array. For your assignments of classes, HP, etc - try incorporate a function instead of brute initialization. This will make your life easier and cut down on the number of meaningful lines of code you have. So:
I'm glad to see you didn't break down and try use Turing's native GUI. Sure your's could do with some streamlining (did I hear someone say something about equationally checking for mouse positions instead of using absolute values?), but at least it meets your on needs. |
Author: | Talion [ Sun Jan 15, 2006 10:47 am ] |
Post subject: | |
Thanks! I think i'll go try that out then. |
Author: | Cervantes [ Sun Jan 15, 2006 10:52 am ] |
Post subject: | |
This type of program will be very difficult to make without a robust knowledge of aggregate data structures. You may not have the time for what I'm about to suggest (assuming this is a final project due soon), but learning about Classes, Object Interaction, and Inheritence and Polymorphism will provide you with the structure these programs require. |
Author: | Talion [ Sun Jan 15, 2006 7:44 pm ] |
Post subject: | |
Thanks to you both again! ![]() Well thanks all! ^__^ your help is really appreciated |