View Single Post
Cpp Cpp's Avatar

JCF Member

Joined: Mar 2001

Posts: 1,557

Cpp is doing well so far

Jun 30, 2009, 10:29 AM
Cpp is offline
Hehe, I could point out a few bugs in that code e.g. music.play("filename.ogg"); automatically sets the music.filename to "filename.ogg" so no need to set it manually. Here's a better OOP approach (just a concept):

Code:
class MusicTrigger : public Trigger (string music_filename, int tile_x, int tile_y) {
	.....code...
	virtual void Tick() {
		int pl = GetLocalPlayer();
		if (player[pl].x == this.x && player[pl].y == this.y) {
			if (music.filename != music_filename) {
				music.Play(music_filename);
			}
		}
	}
	...code...
	... constructor, destructor code...
};

MusicTrigger muse1("cooba.mp3", 25, 25);
EDIT: The best part of this OOP approach is that players don't have to write their own code, they can simply declare existing classes and pass parameters along just like placing events in JCS.
__________________
<a href="http://nmap.org/"><img border="0" alt="Nmap Security Scanner" src="http://images.insecure.org/nmap/images/prop/nmap_bnr_matrix_pfos.gif"/></a>