• Content count

  • Joined

  • Last visited

Community Reputation

132 Neutral

About smiley_horse

  • Rank
  1. This doesn't have much to do with game programming, but I wonder if anyone has any usefull tips or pointers to some info. I want to do following, quite simple task; my comps bios has alarm function (as many others) which can be scheduled to turn on computer on certain clock & date. I would like to access that feature from the os (both xp & linux) so that I don't have to boot into BIOS just to sett it off or on. I use my comp as very loud alarm clock from time to time since I have some difficult time to go up early in the morning, so I really use to change this quite often. Doing this via bios every time is kind-a a$$ pain ... I don't know if there are some programms done to do this already, but I would like to make my own :). I have googled around but I didn't found any good reference or tutorial how to do this. I would like to be able to access it from either c, c++ or java, even assembly is ok ...
  2. There are two ways of thinking about OOP. One seems to be more way where OOP is used rather for modelling - second being more one where OOP is used more pragmatic for code reuse. Modelling aproach: you would sitt and think about interaction between your objects, their functions etc. You would try to modell classes that reflects real problem you have and to be close to real life objects as much as possible. Pragmatic approach: You do as u said in one of your first posts - create your RedKnight class, then other classes, you see what is shared and cut it from your classes and then put in some base class and reuse that code at higher level classes. In pragmatic view you modell classes more after your coding - so that you have to re-type as little code as possible, while in "modelling" way you are more out like making good design to reflect real world as much as possible adn to be easy to understand. Code that is easy to understand is often more easy to update later, after longer time. I am kind-a more into using OOP for modelling approach, but I'm not strict follower of any ideology :). I think that proper modelling is much more important then coding in long run, but sometimes it's just stupid not to modell for easy coding. But if modell woould become to long away from being easy to understand and easy to mirror to real problem, I sacrifice code reuse. I'm not sure if I really make myself clear, but I hope you get the idea what I'm thinking about. I'm trying to be short, nothing in this life is white & black, so isn't coding & modelling neither, so I'm a bit overdriving just to give a picture .... About abstract classes & interfaces: I'm big fun of interface programming. I see interfaces as a good programming paradigm. They make it easy to think about problem solving indeed. You think in terms "this object will do this & thius"; "That object will do that & that"; "to make this I will need object that do this & that" and so on. I don't think so much about how my code will look like or what algorithms to use or such things while I'm designing my classes. Interfaces are a way of generic programming - as Bruce Eckel calls it "explicit generic programming", for difference of "generics" (templates in c++) which he sees as "implicit gen. progr". I kind-a like more explicit one since it's easy to see what methods are needed and must be implemented. I see them as a cleaner and more strongly way of doing generics then templates, while for example templates are good way of putting more work at compile time rather then runtime (but not in java's case). I use abstract classes pretty much as interfaces, but in cases where I want to implement some methods to save me some typing later on. I use them almost exclusively in for example library side (gamelib) that is ment to be used by appllications (games). In my clone of space invaders there is no singel abstract class at game level, but at library level I have for ex. abstract Sprite class that implements for example render() method. probably 90% of game objects uses same rendering method (just draws current frame) so in most of game objects I don't have to rewrite those 2 lines needed to render BufferedImage. Take a peek at Bruce Eckel's site for more reading about OOP. Here is article about generics: .
  3. [java] drawing sprites

    Yeah - I'm also having Sprites as abstract class in my gamelib, with simple render method implemented in abstract Sprite class. I create then Subclasses at app level for different movable objects (like player, alien, bonus clasees etc). Most of them are quite ok with base implementation of render() method which just draws current frame (BufferedImage) on the screen, but some classes override method to implement their own rendering - for example compositing several images . Good thing of doing it that way is that render method is easy to implement - just few lines of code. Also it's easy to add new kind of sprites with different rendering - I never had to touch my original Sprite class. If you were to write main method that loops through different sprites, you would have to make big switch or if/else or maybe some other way to decide what you are drawing as soon as you wanted to implement different way to render different things. However this approach (one render method that loops through all sprites) have one pros - it's only one function call to render() instead of one function call per sprite. But I don't think that speedup is worth having big method that needs constant updating when new things are added - it's easy to mess up. But if yuu would draw all your sprites same way then you can probably make it that approach as well.
  4. Well I setup JFrame to unresizable 600x800 frame and that's all sizes used. But using setSize(int, int) on JFrame, shouldn't be problem, it never was before. As said this is problem if I run with default (xlib) toolkit. When I switch toolkit to Motif I get up JFrame. However problem is those freezings that occur all the time. I have also done some very simple test with only opening a JFrame and then maximizing - minimizing it. I use keyboard for doing it. However when pressing one key, I have to switch to some another window on desk, and then again back to java window, otherwise it doesn't react on keyboard input despite that window has focus. And I have to switch so for every press just to give it focus. When running on Motif toolkit, this still happends sometime, but very rearely. I guess it has something to do with awt iput thred or something there. I can post my simple example on thursday since I'm not at home at the moment.
  5. Is AWT in jdk 1.5_04 on FC4 tottally messed up??? Remember promise compile once, run anywhere? Well I took classes for my game lib & simple space invaders clone that works as espcted on windows xp and try to run them on fc4 as installed from original dvd, with no updates applied yet. I have ofcourse downloaded latest jdk release from sun site and am sure to run with sun's virtual machine not gcj's, as fedora cames setuped to ibm's compiler & gcj's runtime. I have never seen so many problems with java before. When starting up game my JFrame is crippled to something like 5x5 pixel big clump on the middle of the screen. After I digged into docs I found that they have reimplemented awt & swing on linux to use xlib instead of motif. ( ). One can change the toolkit being used as described here: However with changed toolkit from xlib to motif, the game runs but is still unplayable at best. Icons are jumping around the screen & everything is freezing all the time and just plain not working at all. For example whole JFrame & input freezes for sweveral seconds, then it accepts input and animte, then it freezes again & so on ... I haven't had time nor lust to digg into reasons - if it is either something to fedora or jdk. What I wonder with this post if you others are experiencinig same problems? I never before had problems with jdk on linux, it worked just as it would. One day that comes I'll try to install jdk 1.4 on fc4 and see if problem persists, but untill I get the time, it's nice to hear if there is some clue to what might be wrong. And word about my game: it is done only on top of jdk. I don't use any extern java classes, nor native code calls from app side - just pure jdk classes. Only AWT and Swing used is just one JFrame opened for drawing onto and AWTEVent object for polling input. No other widgets at all are used. Everything else including ui is done at app level code with pure java and jdk help. I have also recompiled all classes in fedora, just in case, but no luck it's same thing.
  6. I guess so. ________________________________________________________ However I have figured it out. I found this project and took some peek into code & makefiles:, which was of help. If anyone else is wondering, the process is: 1. create java class 2. compile java class with gcjh to produce header file 3. compile java class again with "gcjh -stubs classname" to get .cc file (optional) 4. compile .cc file with gcc as ordinary c++ file (with -c option) 5. compile java class with gcj, pass it .o file from step 4 Actually there is no difference from using jni, but they could have say that :), it could spare some wondering. [Edited by - smiley_horse on July 9, 2005 10:28:28 AM]
  7. GCJ is used to build native interfaces for Java. Once that is done, you just import the appropriate class file and use it like you would any other java class. Oki ... can u tell me how? That's what I'm asking. Just a simple quetion: have u ever called c++ method from your java prog with CNI? [Edited by - smiley_horse on July 8, 2005 6:13:05 PM]
  8. Thnks for fast anser - interesting; but it's kind-a tool for generating JNI code. However I am looking for info about calling c++ code with CNI, if it's possible.
  9. Looking att gcj manual (about cni section): there is not a word how to call c++ code from java program. Not a singel word or example in whole section. I have also googled pretty much around and there are several ppl offering some basic tutorials and mentioning CNI, but seems like anyone on earth suddenly want to call java from their c++ code. Also is it possible to go other way around, or I have to use JNI even when compiling with gcj? I just need some simple pointer so I can start use CNI ... if anyone has some plz handle it over.
  10. I agree with the last words. And also since vm do goode job on removing garbage, it has less chance to be down because of memory leak or such. I also guess that they probably have a lot of money to invest in good server machines with a lot of ram an probably multi cpu, so I don't think that speed is much of issue there as it is perceived on our ordinary home machines with some poor p4 class cpu and ~512 meg ram as most users probaly have these days.
  11. Rectangle in java is subclass of Shapes which can be arbitrary polygons and even curves if you need such. I suggest you to take look into awt.Shape interface and classes that implements it. Also if you need more precision then ints, then check those classes with 2D suffixes, since those have float or double precision. Maybe Polygon class is what you looking for? Otherwise if you want to implement all intersection testing yourself get yourself a good book about collision detection :). Gino van der Bergen's is highly recomended:
  12. I don't know what u mean by pixel perfect; but in my game every entity have awt.Rectangle object for it's bounds. Rectangle is instatiated to size of it's sprite image (BufferedImage). When I'm updating position (I really use upper left corner for position no separate x,y variables), I move rectangle all the time. Then for collision testing between 2 entities in game all I have to do is to ask boolean b = ent1.bounds.intersects(ent2.bounds); It seems to work perfectly correct in mine game, but maybe you are looking for something else?
  13. About caching - yes of course, I have already implemented caching with hashmap for sound and image files. Those are only resources used actually (beside 1 text file to init game with). Problem here is to init classes from a text file, but without writing file parsing code in every constructor or such nor even once for every game. I don't want to init all classes at once neither. Even better, classes outside of framework woulnd't have to deal with any form of file parsing, while classes inside framework would not have to know class names in particular game in advance. I have solved this with help of generic "GameClass" - It turned to be much easier then I thaught it would be. I have one class in framework to read text file which name I pass in constructor to that class. Game can then ask for particular class name like "getClass("Player") for ex. File reader will then attempt to find given name in textfile and read in all associated attributes & values in a "GameClass" object (with hashmap for attributes). Then "GameClass" object is passed to constructor of class that needed it so it can read data specific to only that one object (like number of lifes for player or such). "GameClass" also has some common code for all classes to get attributes (like getSpeed() or such which returns number instead of String for parsing). So only code that really do file parsing is in framework in FileReader object, once and for all. Only thing a new game object has to do is to ask for GameClass with it's name and then read in data it needs from returned GameClass object. Some minor parsing of strings is still neccessary since hashmap stores all attributes as strings, but that's really minor thing to do. I don't know how good is this approach, however it works. It would be nice to see some other solution. By the way. I thaught about XML myself. I am using 1.5 version and I know there are xerces and xalan (or what are names) that cames in jdk, but I never used them. I was looking at few books, but I didn't want to spend a week or two on reading a book and experimenting when I can generally parse text file in 5 lines of code with BufferedReader. However if there is some good tutorial (fast to read) I would be glad to read it and implement xml instead of custom text syntax.
  14. Hi guys, I have written little java framework and now a space invaders clone based on the framework. However I am in need of good design for resource loading. I have some ideas on my own how to do it, but I wonder if there is some standard way of doing it. Problem is like this: another person is working on gameart and I want him to be able to define & load resources without compilation. As it is now, he can ofcourse write over old pictures & sounds with new ones since there are some hardcoded strings for player, alien etc. But hardcoded strings means for example that he can't change number of frames of animations without recompiling. What I plan to do is to make a simple text file, which will be read when game starts and it will contain all data for various classes with attributes & file references. Question is how to implement creation of classes with least overhead in both size & time? Factory pattern - one class to read file and other classes will request objects when needed? Or using factory to create all other game objects and pass them around to pieces that needs them in constructors or alike? I would also like to make factory class rather part of framework then particular game. What is standard way to do such things in games? Problem is that framework should not have to know what classes are needed in particular game, and I still don't want to rewrite factory class for every game. So is there a good way to dynamicly find objects in game without hardcoding class names in some if-else statement? Or maybe it's not the way to go? Help is highly appreciated. cheers :-) ______________________________________ edit: oki I think I'm looking for something like Spring, but simpler and much less in size. Any good pointer? [Edited by - smiley_horse on June 28, 2005 12:20:31 PM]
  15. Online jobs

    Interesting thread ... Is there anyone that have ever earned some money from online projects? I'm in sweden and just wonder if there is some serious site where one can find such projects and ofcourse the site where one can trust that ppl will pay?