ShannonSmith
|
 |
«
Posted
2008-11-25 08:50:40 » |
|
After getting inspired by Marcus's TinyCham I started creating my own 40x30 pixel adventure. I didn't get particularly far because I got quite sidetracked on a separate project which I will go over below. Anyway here is what I have thus far:  I got sidetracked when I started looking at music for the project which I haven't yet added to a game but am convinced of it's importance. I have tried creating a software synthesizer/sequencer to replace the horrible java.midi api several times but never been particularly successful. This time for some reason the design just worked and I ended up with something I am very happy with. I created a demo applet which you can try out by clicking on the screenshot: I will release a library soon that should enable you to have full (albeit electronic sounding) music tracks in a game for less than 80k. I think I might chop down a version of it for this years 4k comp (always been meaning to enter it) and try making rhythm game (also something I have been wanting to have a go at).
|
|
|
|
|
zammbi
|
 |
«
Reply #1 - Posted
2008-11-25 09:03:35 » |
|
Sure can make some cool/funky sounds hehe. I may use such a library in the future to keep my game size down.
Ill give the game a try later.
|
|
|
|
|
|
Games published by our own members! Check 'em out!
|
|
CommanderKeith
|
 |
«
Reply #3 - Posted
2008-11-25 14:13:34 » |
|
That game is cool, and the music really gives it a spooky feel. You must be a musician because it's really quite awesome. I liked the piano applet too. The random button is good. By the way, a good fellow named Bleb made a similarly cool program that did synthesised sound effects, I'll try and find a link... it's somewhere on JGO, in shared code. The game needs more baddies though, I couldn't find anyone. Oh and the map should be a little bigger if possible, and what about scaling up the world so it's still got a pixelly-feel but it takes up more screen space... just an idea. Nice work 
|
|
|
|
irreversible_kev
|
 |
«
Reply #4 - Posted
2008-11-25 17:43:51 » |
|
The game needs more baddies though, I couldn't find anyone. You didn't find the spider?  (He lives in a cave, EDIT: and in the castle)
|
|
|
|
|
ShannonSmith
|
 |
«
Reply #5 - Posted
2008-11-25 18:09:49 » |
|
Thangs guys.
irrevessible_kev: You explored too much... Also the sound crackling is probably because the audio buffer size is really low (for low latency key response). The library version of this will have a customizable buffer size when you create the Synthesizer so you can tailor it toward real time (small buffer) vs background playback (large buffer).
CommanderKeith: As noted, there is a single enemy (that you can't kill and just walks around randomly) in the cave/castle. I would have created more but as mentioned, got sidetracked. The world is scaled at x4 at the moment but if I continue developing (frankly unlikely) I will add 1x - 8x zoom.
|
|
|
|
|
Markus_Persson
|
 |
«
Reply #6 - Posted
2008-11-25 19:23:37 » |
|
That.. is amazing. You need to finish it. =D
|
|
|
|
ShannonSmith
|
 |
«
Reply #7 - Posted
2008-11-25 19:35:41 » |
|
That.. is amazing. You need to finish it. =D
You first! 
|
|
|
|
|
hishadow
Senior Newbie 
|
 |
«
Reply #8 - Posted
2008-11-25 20:15:58 » |
|
Very cool synth (can I request virtual-piano mapping from keyboard?  ). I've always wondered why audio-processing in game seem to be living in the stone-age while 3d-graphics have moved beyond imagination.
|
|
|
|
|
ShannonSmith
|
 |
«
Reply #9 - Posted
2008-11-25 20:21:17 » |
|
Good idea, might add that tonight. I have a MIDI keyboard so haven't really had the need to input notes with my computer keyboard, but that would be pretty handy.
|
|
|
|
|
Games published by our own members! Check 'em out!
|
|
hishadow
Senior Newbie 
|
 |
«
Reply #10 - Posted
2008-11-25 20:27:46 » |
|
Good idea, might add that tonight. I have a MIDI keyboard so haven't really had the need to input notes with my computer keyboard, but that would be pretty handy. That would be cool. I used to use the Virtual Piano with my Yamaha DB50XG, though it's not particulary touch-sensitive. It's pretty much hammering the keys. 
|
|
|
|
|
Morre
|
 |
«
Reply #11 - Posted
2008-11-25 21:39:36 » |
|
I know you might not keep working on it, but for what it's worth, you cancel the players movement when I exit a house (making me click the down arrow twice). It's unneccessary.  Really cool stuff! 
|
|
|
|
ShannonSmith
|
 |
«
Reply #12 - Posted
2008-11-25 23:05:53 » |
|
I know you might not keep working on it, but for what it's worth, you cancel the players movement when I exit a house (making me click the down arrow twice). It's unneccessary.  Really cool stuff!  It just felt like a bit of a harsh/discontinuous jump if you just kept walking after you were teleported outside. I should probably have you keep walking but have a brief black screen or a pause so it's not quite so jarring.
|
|
|
|
|
Scarzzurs
|
 |
«
Reply #13 - Posted
2008-11-26 00:03:18 » |
|
Hey. I Tried the game. I really like this style. Your sword attacks are great, aswell as walk-animation. :-)
I gotta ask this though: What are the controls? Also i got the problems described below when i played the game:
****************** Spoiler alert! (Mark to read) ******************
The spider in the cave tried to escape through the cave entrance. I tried to follow but got stuck in the cave entrance on top of the spider, which was also stuck. I rebooted again, got to the room that told me to stop exploring, went to the next room, and got stuck again! I think a spider was involved again... Also I'm starting to get arachnophobic... Third time i thought i had explored it all and quit. I really wanted to open the chests, but failed at finding a way... :-(
It wouldn't hurt to have the window center on screen btw. :-)
- Scarzzurs
|
|
|
|
ShannonSmith
|
 |
«
Reply #14 - Posted
2008-11-26 00:16:08 » |
|
Hmm, yeah there is nothing stopping the spider from traveling through doors at the moment. And the second he gets far enough away from you he stops moving so you will teleport inside him and get stuck. I'll have to fix that one. As for chests, they are purely cosmetic at the moment. Can't be opened and don't contain anything. My original idea for this game was to see if I could have a compelling story and atmosphere in only 40x30 pixels. It is very hard to write any text for the game due to the size constraints but I hoped that when pared down it could still be an engaging experience that would take around 30 mins to complete. If it became popular I was thinking I could try doing an episodic format (always such grand plans when I start). I planned to have Episode 1 start with an earthquake that cause the rock-slide that is blocking the path out of the village. In the course of getting the rock-slide cleared you would discover it had a sinister origin and end up having to embark on a quest to save the world (or something along those lines). Episode 1 would finish when you left the village.
|
|
|
|
|
oNyx
|
 |
«
Reply #15 - Posted
2008-11-26 00:57:58 » |
|
Awesome stuff. Really like the music. Being able to work diagonally (no need for extra animations... even SNES games didn't bother with it in many cases) would be nice. The synth stuff is also really great. Too bad that one can't use the keyboard right now. Do you intend to release the code for the lib as well? Would be ace. 
|
|
|
|
ShannonSmith
|
 |
«
Reply #16 - Posted
2008-11-26 01:09:56 » |
|
Cheers, Yeah will probably allow 8-dir movement (once again, inspiration permitting) in next release. Generally I at least GPL all my source code if anyone asks so I'll probably start a GoogleCode or SourceForge project for SimpleSynth when I get some free time.
|
|
|
|
|
ShannonSmith
|
 |
«
Reply #17 - Posted
2008-11-26 17:34:16 » |
|
Sorry to hijack my own thread but I was trying to implement a keyboard control for my synthesizer and ran into an interesting problem. Is there any way in Linux to reliably detect the state of any key without getting the Security Manager throwing a hissy fit? I really don't want to have to pop up a permissions dialog just so keyboard control works properly.
|
|
|
|
|
hishadow
Senior Newbie 
|
 |
«
Reply #18 - Posted
2008-11-26 19:40:43 » |
|
Peculiar dilemma. I'm pretty sure that would be impossible, or else you'd be able to monitor keystrokes outside the webpage. You'd could probably use threads to build up a buffer for choords, but it seems like much work for the request. 
|
|
|
|
|
ShannonSmith
|
 |
«
Reply #19 - Posted
2008-11-26 20:30:30 » |
|
I don't need to keep keyboard focus, the problem I have is that on Linux key repeat works by sending multiple pressed/released events while a key is held. The only way I know around this is to take a look at the AWT event queue (needs security permission) and ignore any release events that have a subsequent press with the same timestamp.
|
|
|
|
|
CommanderKeith
|
 |
«
Reply #20 - Posted
2008-11-27 01:31:54 » |
|
Hi,
One thing that could be improved in the movement of the player is that when you press two keys at once, the player should do what the last key pressed did, rather than continuing to honour the old key press.
Here's a class I used to take that into account, maybe it will be useful (This may help with your other problem too?):
import java.io.*; import java.util.*; import java.awt.event.*;
public class PlayersCurrentDirection{ // If empty, the player will not be trying to move // The last pressed keys are first. ArrayListSS<Integer> directionsPressed; int direction; public PlayersCurrentDirection(){ direction = DOWN; directionsPressed = new ArrayListSS<Integer>(); } public void stopMoving(){ directionsPressed.clear(); } // this should really be called isTryingToMove, since it doesn't return whether or not the player is actually moving. public boolean isMoving(){ return (directionsPressed.size() > 0 ? true : false); } public int getDirection(){ return direction; } public void applyKeyEvent(PlayerKeyEvent e){ if (e.getKeyEventType() == e.KEY_PRESS){ if (e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_A){ addDirection(LEFT); }else if (e.getKeyCode() == KeyEvent.VK_RIGHT || e.getKeyCode() == KeyEvent.VK_D){ addDirection(RIGHT); }else if (e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_W){ addDirection(UP); }else if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_S){ addDirection(DOWN); } }else if (e.getKeyEventType() == e.KEY_RELEASE){ // Here we remove the key from directionsPressed if it is present. // Note that we must remove all occurences, since there may be more // than one of the same key press in the list if something weird happened. if (e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_A){ removeDirection(LEFT); }else if (e.getKeyCode() == KeyEvent.VK_RIGHT || e.getKeyCode() == KeyEvent.VK_D){ removeDirection(RIGHT); }else if (e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_W){ removeDirection(UP); }else if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_S){ removeDirection(DOWN); } } } protected void addDirection(int dir){ if (directionsPressed.size() == 0 || directionsPressed.get(0).intValue() != dir){ directionsPressed.add(dir); direction = dir; } } protected void removeDirection(int dir){ for (int i = 0; i < directionsPressed.size(); i++){ if (directionsPressed.get(i).intValue() == dir){ directionsPressed.remove(i); i--; } } if (directionsPressed.size() != 0){ direction = directionsPressed.get(0); } } }
|
|
|
|
|
|
ShannonSmith
|
 |
«
Reply #22 - Posted
2008-11-27 03:46:27 » |
|
Ok, got the key thing sorted, new version up. This is probably the ugliest hack I have ever done but basically after any keyPressed/keyReleased events I keep track of the key state according to AWT and start a Timer with a 5ms delay. The timer actionEvent then compares the AWT key states with it's own set of key states and issues it's own events based on the differences. This seams to fix the Linux press/release key repeat issue as the press/release events appear to go into the event queue in pairs and when the timer goes off I have never had a key that was held down in the up state. Oddly I tried an SwingUtilities.invokeLater() to do a similar thing but I was getting keys up occasionally so I am not sure what's up with that. Yeah, I saw that a while back. Quite nice but could really use a demo applet or at least a webstart link. Hi,
One thing that could be improved in the movement of the player is that when you press two keys at once, the player should do what the last key pressed did, rather than continuing to honour the old key press.
Here's a class I used to take that into account, maybe it will be useful (This may help with your other problem too?):
I don't think that class is quite necessary, all you need to do is set the direction to the most current key pressed and only stop if the released key matches the current player direction.
|
|
|
|
|
oNyx
|
 |
«
Reply #23 - Posted
2008-11-27 06:05:45 » |
|
>I don't think that class is quite necessary, all you need to do is set the direction to the most current key >pressed and only stop if the released key matches the current player direction.
The usual way to do that is simpler than that.
dx=right-left dy=down-up
Ye... that's all. (Directions are int flags where 0=not pressed and 1=pressed.)
Opposing directions cancel each other out and everything else just works.
|
|
|
|
CommanderKeith
|
 |
«
Reply #24 - Posted
2008-11-27 06:32:06 » |
|
My little bro gave me the thumbs up when I implemented this method, since it meant that he could press down while pressing up, and the player would change direction by going down. Then when he released down, the player would head back up since he never released the up key. It does feel nice when the game remembers what keys you've got down, but obviously the added complexity might not be worth it. each to his own  Also, often key presses are streamed continuously even when multiple keys are down, so doing whatever the latest key press was isn't necessarily the best option.
|
|
|
|
|