Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Space Conflict

Author
Message
Libervurto
12
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 10th Jan 2013 10:46 Edited at: 10th Jan 2013 15:26
A little bug-fixing help needed here.
[edit]
It seems the issue was declaring an array using a value from another array
dim ship#(ship_lim(0),15)
I don't know why this would pose a problem but it's fixed now.


Anyone want to help me improve this game? The code still needs a lot of tidying up and there are some bugs creeping in; although this is greatly improving with time.

Shh... you're pretty.
Fluffy Rabbit
User Banned
Posted: 10th Jan 2013 17:20
I added sound. I'm not really sure of the mechanics of the game, so:

1) There should be a help screen when the game starts.
2) Maybe you could add more sounds for each individual thing that could happen.

Libervurto
12
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 10th Jan 2013 19:03 Edited at: 10th Jan 2013 23:05
@Fluff - Nice, I came here to post something myself so I'll get back to you on that.

Here's another of IBOL's programs that I've heavily edited (he writes some clever stuff but MAN is his code a mess! )

It's a procedural spaceship generator:
[edit: code updated]


@Fluffy
Well that might as well be magic to me!
I understand how the strings work though so I was able to make a theme tune. However, going up a few octaves throws the notes out of tune for some reason.

Shh... you're pretty.

Attachments

Login to view attachments
Fluffy Rabbit
User Banned
Posted: 10th Jan 2013 20:40
Firstly, 2 is octave 1, 1 is octave 0, etc. just because of notation. Secondly, the bitrate is what causes the distortion at higher pitches. The samplerate variable can be changed to something like 48000, although the higher it is, the longer it takes to generate the music.
Libervurto
12
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 11th Jan 2013 11:29 Edited at: 11th Jan 2013 14:44
I've improved the procedural ship generator:


A version for faces:


Shh... you're pretty.
Fluffy Rabbit
User Banned
Posted: 11th Jan 2013 13:01 Edited at: 11th Jan 2013 13:02
Cool. It still seems like the ships are scaled up to about twice their resolution, though.

EDIT: The faces look like space ships.
Libervurto
12
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 11th Jan 2013 13:49 Edited at: 11th Jan 2013 15:53
Quote: "The faces look like space ships."

Yeah I think the faces need a lot of work before they look good, I didn't even change the colour generation. I started from scratch for the planets and they look awesome!

Planets:
[edit: BIG UPDATE]


Shh... you're pretty.
Fluffy Rabbit
User Banned
Posted: 11th Jan 2013 16:25 Edited at: 11th Jan 2013 16:26
@OBese-

Firstly, why not generate a 2:1 ratio planet texture instead? It would be easier to make and it could be dropped onto a sphere, effectively making a very realistic planet with minimal effort. Secondly, why do so many planets look like Jupiter, what with the bands of gas? Why not make Class M planets with oceans and such?

The ship generator was good, the face generator was horrible, and the planet generator has a lot of potential but just isn't there yet.

Also, what's with the 2x scaling of the resolution on the screen?
Libervurto
12
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 11th Jan 2013 19:33
I'll definitely redo the faces and ships from scratch now that I understand this method better. Planets are great for testing things out and learning because they're pretty simple.

When you say "like Jupiter" do you mean there are too many banded planets or the band colours are too different or both? It's pretty easy to change all that, it's just one or two numbers, tweaking them to get them right is tricky though. The scale is a parameter of the draw function, I just like it at x2 because it's easier to see the details.

Shh... you're pretty.

Attachments

Login to view attachments
Fluffy Rabbit
User Banned
Posted: 11th Jan 2013 19:37
Yeah, I'd say keep the ship gen code because it was pretty amazing and get rid of all of the bands on the planets. There are very few gas planets out there, and only a gas planet has bands like that. Also, why not do high-res 3D planets? You could generate a texture, put it on a sphere, and take a low resolution snapshot, ultimately giving a better-looking image.
Libervurto
12
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 11th Jan 2013 22:21 Edited at: 11th Jan 2013 23:43
There are lots of gas planets. I'm not going for anything hi-res, but feel free to experiment.

I've redone the ship generator:
[edit 22:38]
Now you can pass a colour to the colour generator function and it will make a colour scheme around it. I've put together an example with some possible faction colours.


Shh... you're pretty.

Attachments

Login to view attachments
Fluffy Rabbit
User Banned
Posted: 11th Jan 2013 23:42
Fine, don't take any of my advice. While you're at it, you should probably finish the Space Conflict game. Maybe you can make it make sense.
Libervurto
12
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 11th Jan 2013 23:50
I did take your advice, a lot of the changes I've made to these programs are from your feedback. I didn't carry your suggestion about making a high-res texture because I'm not making a hi-res game. There's no need to get angry.

Shh... you're pretty.
Fluffy Rabbit
User Banned
Posted: 12th Jan 2013 00:22 Edited at: 12th Jan 2013 00:23
I have every right to be angry! You propose something and then I get involved and then you suggest something and then I suggest something and then you disagree and then I re-assert and then you argue and I'm mad! Why can't you just take my advice? Also, what do you mean YOU are not making a hi-res game? WE are making a game, and I want it to be more hi-res. It's already at 1024x768, which is like the maximum monitor resolution of a lot of computers these days, so what the hell? It's disagreements and disputes like this that got me fired, and I'm not going to let some punk on the internet screw around with my perfectly good ideas, and backtalk me, and disrespect me, and be a total dimwit when I could be doing other things. I am OUT. I will not contribute any more to this. If you want to screw around and make bad design decisions, that's on you. I will not be responsible for making a bad game. I have never produced anything of low quality that I did not intend to have low quality. Unless you're trying to make the worst computer game of all time, I'd suggest you pull out too.
BN2 Productions
15
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 12th Jan 2013 01:33
@Fluffy:
I normally stay out of these things, but I'm drawing the line here.

Look, man, you need to chill out. This is a forum for a language that is so ignored by it's original developers that they made its upgraded version free while this one still costs money. We are here to ENJOY ourselves and help each other, not tear each other down. And most importantly, we do it with respect.

Sometimes we all have ideas that, while good ones, are not going to be adopted by others. There can be plenty of reasons for this. The important part is to not take it personally.

And for the record, I see no instance of backtalk or disrespect and calling someone who disagrees with you a "total dimwit" is completely uncalled for. When you suggested something he merely said:

Quote: " I'm not going for anything hi-res, but feel free to experiment."


That isn't disrespectful, nor is it "backtalk". This is actually a very reasonable response (he could have actually been disrespectful about it). If you want respect from people, the best way to do it is to show respect first.

That's all.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Libervurto
12
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 12th Jan 2013 16:56 Edited at: 20th Jan 2013 13:06
I've spent a long time working on the colour generation and it's really paid off!

Lots of variety:
Distinct Factions:



Shh... you're pretty.

Attachments

Login to view attachments
TheComet
11
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 17th Jan 2013 10:29 Edited at: 17th Jan 2013 10:30
Quote: "It's already at 1024x768, which is like the maximum monitor resolution of a lot of computers these days"


Seriously? That may have been the case back in the 20th century, but certainly not today.

@ OBese87

Those spaceships look absolutely fantastic! I can't spot one that is the same as the other.

Sorry to be so misinformed about your project. What's the main concept? Is it like an RTS where you can point/click your space ships? Or is it some form of a top-down shooter?

I'm watching you.

EDIT: Before I forget, is the "OB" in "OBese87" purposely capitalised, perhaps referring to a certain woman's product?

TheComet

http://blankflankstudios.tumblr.com/
Quote: ""
- Randomness 128
Libervurto
12
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 20th Jan 2013 13:04
@Comet
Space Conflict began life as a 20-liner by IBOL: Begin the journey.

Shh... you're pretty.
Libervurto
12
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 22nd Jan 2013 05:12 Edited at: 22nd Jan 2013 20:36
Hey Fluffy,
I've been working on your sound generator, it's pretty neat , I've made a few changes:
* Changed annotation characters to CcDeEFfGaAbB, this is more like what I'm used to so it's easier for me.
* Changed frequencies to a higher octave and made them floats# to improve data loss problems when scaling.
* Added the ability to specify note-length using curly braces, eg: 3C{16} plays a C in octave 3 for 16 samples.
* Simplified some of the equations, but I still don't understand how it actually works.
* Sounds are now created like objects, i.e. [sound name] = newsound([bps],[music$])

[updated: 19:36]




"I am a big dumb babby! " - TheComet
Libervurto
12
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 22nd Jan 2013 21:54
Game code updated with sounds:




"I am a big dumb babby! " - TheComet
Libervurto
12
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 23rd Jan 2013 00:27 Edited at: 23rd Jan 2013 02:18
Just in case anyone is interested in what I'm doing, I'm using that string replace function to edit the array names in the main file.


It took a while to write the function but I think it's well worth it considering the amount of changes that have to be made that can't be done with the regular "replace" function of the editor.

[edit]
There's an issue I did not foresee with replacing the strings:

The only thing I can think to do is make the program count the number of open brackets.

I'm going to have to ditch IBOL's code and start from scratch if I can't figure this out.



"I am a big dumb babby! " - TheComet
Libervurto
12
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 24th Jan 2013 05:44 Edited at: 24th Jan 2013 05:46
It's ridiculously late at night, but I've finally managed to write a string replace function that wont destroy brace structure. I can't believe this has been such a tricky function to get working properly. I've re-written it about five times now! I must learn not to try and be too clever and make everything recursive.
I learned today that writing LOTS of functions is always a good idea. Apart from anything else it makes coding easier since there's less clutter.



[edit] I just remembered they aren't called braces! These are braces: {}; These are parentheses: ().



"I am a big dumb babby! " - TheComet
Fluffy Rabbit
User Banned
Posted: 25th Jan 2013 07:45 Edited at: 25th Jan 2013 10:32
@OBese87-

You have been putting a lot of effort into this project. I feel your pain!

I checked out your last updated version. The music is beautiful, although it's still not incredibly clear what one is supposed to do. So, I can't comment on the gameplay. However, I can comment on the changes you made to my sound generation function. While you improved its functionality, you reduced its efficiency. It is now a whole lot more complicated. Now it's my turn to try to understand it.

What I was going for was some simplified variant of the A-major scale. You changed it to C-major. CcDeEFfGaAbB. Mine was aAbBcCdDeEfFgG where lower-case were regular and capital were sharp. Obviously, I added in D-sharp and G-sharp while keeping the other notes the same pitch (or something like that, I can't remember exactly). QBASIC uses the standard C scale, so I guess you're on the right track, but I'm still not sure which are the sharps- lower case or capitals?

I don't know why you suddenly couldn't get the SELECT statement to work. Your IF-THENs reduce efficiency.

Also, did you change the default octave or something? The frequency is almost double, which slows down generation of music. The specific number I used (26624) I got through trial and error, trying to balance efficiency with distortion. Of course, that may no longer matter now that you're using floats. I can't understand your mathematical reasoning behind all of this, but is there less distortion now on the higher octaves? Would it be possible to lower the frequency and still keep the sound clarity due to the use of floating point numbers, or what?

A couple other things to note: The maximum sound number is 1024, not 255. There's no point in adjusting the volume inside of the function (I know it means less code, but the purpose of the sound generation function is only to generate sounds.)

I'll try to work on the things I mentioned. Oh, boy.

EDIT:

Also, it's cool to see how you're making progress on other areas of the game. I don't understand how your string search function ties into it. (Don't bother explaining it to me.) I wonder how this will work when all of the little pieces are finished and brought together...

EDIT 2:

OK, Here's the "fixed" version of the sound generator. It isn't much, but it's all I can contribute to the project right now.

Libervurto
12
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 25th Jan 2013 17:13 Edited at: 25th Jan 2013 18:29
Quote: "I'm still not sure which are the sharps- lower case or capitals?"

The capitals are the normal notes and the lower case are the sharps, except 'a','b' and 'e' are actually flats... yes that is overly confusing and I will change them all to sharps. (So those three will become 'g','a' and 'd'.)

Quote: "I can't understand your mathematical reasoning behind all of this, but is there less distortion now on the higher octaves?"

Here are the frequencies of C in the first eight octaves:
0C = 16.35
1C = 32.70
2C = 65.41
3C = 130.81
4C = 261.63
5C = 523.25
6C = 1046.50
7C = 2093.00

This is what we get by starting at 7C and scaling down:
7C = 2093.00
6C = 1046.5
5C = 523.25
4C = 261.625
3C = 130.8125
2C = 65.40625
1C = 32.703125
0C = 16.3515625
The last frequency is 0.0015625 out. 0.0000955657%

This is what we get by starting at 0C and scaling up:
0C = 16.35
1C = 32.7
2C = 65.4
3C = 130.8
4C = 261.6
5C = 523.2
6C = 1046.4
7C = 2092.8
The last frequency is 0.2 out. 0.0000955566%

I didn't expect the percentages to be that close, and I'm not sure whether that's what's important, but there's certainly less data loss when starting with the largest number.

[edit]
I've taken what you posted and changed the note annotations to what I said above. I also randomly played around with the byte data part and got some interesting sounds. Maybe we can have different instruments?


Something I'd really find useful would be the ability to read in from an external file, and read more than one string into a sound. (Traviata melody stops abruptly because I hit the string limit. )

Meanwhile...
Fluffy Rabbit
User Banned
Posted: 25th Jan 2013 22:42 Edited at: 25th Jan 2013 23:46
@OBese87-

I'm glad to hear you changed the note annotations, and I'm also happy to see that you have internalized the snippet$ function. The instruments, on the other hand, don't seem to really do anything. I mean, I noticed some slight difference on instrument 5, but that's about it. My advice would be aiming to change the waveform entirely with each instrument (square, sine, sawtooth).

I'll try to work on an appendSound function.

EDIT:

I'm getting memory errors. If this bug could be squashed, we'd be able to have unlimited-length sounds.

Libervurto
12
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 26th Jan 2013 03:08 Edited at: 26th Jan 2013 04:03
Hey, I've just added some short-hand notation for common beat lengths 4,8 and 16. You don't have to use them but I find it easier to type and it helps cut down string length (soon that might not be an issue!) I made a new song too.


I'll take a look at this bug.

[edit]
I pasted your code into a new function and changed it to stick two ready-made sounds together. And it works!


Ah I must have made an error with the data somewhere. It works with one appended sound but trying to append the same sound again throws an error.

Meanwhile...
Fluffy Rabbit
User Banned
Posted: 26th Jan 2013 07:00
Well, it sounds like you need to fix the error.
Libervurto
12
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 26th Jan 2013 17:32 Edited at: 26th Jan 2013 17:49
I had another look at your code and it turns out I was using the wrong numbers for the header. Fixed:


A nice side-effect is that you can append a new sound to a previously created one:
appendSound(oldSnd,newSound(16,"4C'D'E'F'G'A'B'5C'"))
This is because newSound() returns the number of the sound it just created.

Now to combine melody and bass into one sound! I have no idea how to begin doing that.

Meanwhile...
Fluffy Rabbit
User Banned
Posted: 27th Jan 2013 06:37
@OBese-

I tried to slap together a function to overlap two sound files by dithering, but I just can't figure it out. It seems like only the first sound file that's playing. It's probably some small bug I'm overlooking, but I'm too tired to continue.

Libervurto
12
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 27th Jan 2013 19:41
I didn't like that it was deleting the original sound so I changed it to make a new one from the merge, and for some reason that fixed it! Well it doesn't sound great but your idea works in principle. Maybe the merged sound needs to be twice the bps?



Meanwhile...
Fluffy Rabbit
User Banned
Posted: 28th Jan 2013 03:08 Edited at: 28th Jan 2013 04:40
I find that I get the best results when changing dithsize from 4000 to 2. I tried averaging the waveforms, but that produces strange artifacts. I tried adding the bytes, but that actually makes it way quieter. Then I realized something. The volume of the sound is based on amplitude, or the difference between the high part and the low part of the wave. So, if the wave is irregular (not sine or square) as can occur with dithering and averaging, the volume goes down or we get strange sounds. The computer effectively adds the current amplitude of each sound when playing multiple at once. I have no idea how it does that, although I can imagine a non-linear formula where each sound playing at once adds less and less amplitude the more sounds there are.

In other words, the amplitude is averaged, not the waveform. The frequency stays the same. Here is what Audacity does (before and after a Quick Mix):



It appears that Audacity literally takes an average of the two sounds, just by averaging all of the bytes. However, when I average all of the bytes in the mergeSound function, it goes crazy.

EDIT:

It's not perfect, but here's the closest I've come so far to matching what it sounds like when playing two at once. Part of the problem is that when a byte=0, it sometimes represents silence and sometimes represents maximum amplitude (distance from 128 is 128). Somehow I've been able to work around that. Here's the thingy so far (I don't want to mess it up as I experiment further). The only problem now is that it's a little quiet.



EDIT 2:
Screw it, I've been working at this for hours. Maybe you can figure out how to make it louder.

Attachments

Login to view attachments
Libervurto
12
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 28th Jan 2013 09:52
I've created dubstep!

No I don't really know what I'm doing with soundwaves.

Meanwhile...
Fluffy Rabbit
User Banned
Posted: 28th Jan 2013 10:42 Edited at: 29th Jan 2013 02:02
@OBese-

Yeah, it's amazing what increasing a value by 1 can do. I've found that when tbyte is multiplied by 64 instead of 63, it can equal 128. At 127, there is no distortion. At 128, it sounds like dubstep. It's interesting that we still get this effect when you subtract it from 255, which would change 128 to 127. Therefore, it is safe to assume that it goes all funky when when there are values both below and above 127.5. What I should do is save the memblock of a correctly merged sound, then open it with Audacity and see what happens when I amplify it.

EDIT:
Well, I did exactly what I said I would do, and you know what? The waveform looks the same. It's not a whole lot louder either. The way I figure, If we really need things to be louder, we can make a separate function to amplify sounds later. For now, the music sounds silky smooth, so I'd recommend we move forward.

By the way, for whatever reason, the mergeSound function is not compatible with b = ang#*.711.
Libervurto
12
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 16th Feb 2013 06:21
I've decided to move this project over to DBP. I wont be posting any more updates here but I'll post a link to the new thread once I have enough running in DBP to warrant it.

I feel strangely guilty like I'm putting down the family pet. You had a good life DBC...

Login to post a reply

Server time is: 2019-06-17 10:28:48
Your offset time is: 2019-06-17 10:28:48