Random Experiments

It’s fun experimenting around with ideas that strike you at random times. Someone, somewhere might get some use out of this topic, whereas most of us surely will be at least a bit amused by it. As for me, well, I’d like to make the first post! (And obviously, I did.)

So here’s my experiment for the day:
Fake lighting in 2D games.
I took my 2D OpenGL template (utilizing Guy Perfect’s lovely CometGL class–“an abstraction of normal OpenGL calls,” as he put it) and added a texture to it. The texture, in MS Paint, appears to simply be pure black; however, it is a 32-bit bitmap. My program loads 32-bit bitmap files and treats the reserved bits as alpha, whereas other programs ignore the additional bits. So what I did for the lighting is make a fuzzy, blurry circle shape in Photoshop, saved it as a bitmap, and used a new program I made earlier today to merge that with the 24-bit RGB file. Then in the experiment program, a background is drawn, then a bouncing square, then four barely-transparent black rectangles, and then the new texture. It looks pretty sweet, if you ask me. VB coders, feel free to download the source code. Oh, and by the way, it has sound and some random music whose download location I don’t recall.
EXE
Source code

If the links don’t work, it’s Geocities’ fault, but you should be able to get to the files by pasting the link in your address bar.

Oh, and here’s a screenshot. Note that I was running it through Remote Desktop at the time, so the frame rate it shows is awful compared to what you should get. With my integrated graphics card, I could easily manage >375 frames per second when I removed the limiter. (FPSC = frames per second calculated; FPSD = frames per second drawn. I set it up so that it can’t skip more than one frame at a time even if it’s running really slow.)

Copy-and-paste of a post I made later:
I’ve updated my source code to load a room I made in a hex editor (yeah, I seriously did it by hand–I also made some mistakes, it seems). Also, if anyone looked at or messed with the source code… Change the line “StretchAmnt = 1” to change the size of everything but the window itself.

New links:
EXE
VB6 Source

Sounds awesome, but I couldn’t make the D/L start…

You can do that with GM, if you do a centered gradient in the disk. Though this must be tougher with OpenGL.


Experiment stats, showing that I can make my games run quite smoothly from now on:
115+ FPS with BG layer, the box, foreground layer, and Light layer, 365 x 233, on my 2.0 GHz AMD Sempron with an ATI Radeon M200 integrated graphics chip.
Maxed at 138 FPS when compiled.
Maxed at 69 FPS compiled, with a resolution of 1280 x 721 (without resizing the layers themselves, except the darkness layer).
244 FPS at 192x144 with no layer resizing (again, except the darkness layer).

Wow, that’s pretty cool.

I wanted to add a similar effect to my own engine, but seeing your work makes me want to do that even more :smiley:, it looks really nice.

Here’s my random experiment:

Beeps v2

One day, my brother was playing a DOS game(Dangerous Dave) which used the internal pc speaker (with all the annoying sounds…). For some strange reason I wanted to know how to make those sounds and I found the Windows function ‘Beep(Hertz, lenght)’.

The pcs at my school don’t have normal speakers, so I figuered I could do some fun stuff with my new knowledge… Well this is how Beeps began.

Beeps let you make ‘music’ through the internal speaker, by pressing keys on your keyboard. The program runs in the background (so teachers couldn’t find out where all those annoying sounds came from). It’s coded in C++ and utilizes DirectInput for input

controls:
Spacebar: Random beeps
Num0: sounds off
Num1: 1st octave
Num2: 2nd octave
Num3: 3th octave
Num4: 4th octave
Num-/Num+: adjust note length

Tab ~ Backslash: White keys(c, d, e, f, etc)
1 ~ Backspace: Black keys(c#, d#, etc)

Shift + Esc: Quit (!)

Download

I’ll upload the source if anyone wants it…

Iv’e needed something like what Mason came up with for my engine in GM6.

Here’s what I came up with. //Create fodark=surface_create(window_get_width() ,window_get_height() )

//Step
surface_set_target(fodark)
draw_clear(c_white)
draw_circle_color(mouse_x,mouse_y,128,c_black,c_white,0)
surface_reset_target()
//Draw
draw_set_blend_mode_ext(bm_add,bm_inv_src_color)
draw_surface(fodark,0,0)
draw_set_blend_mode(bm_normal)

Heh, that Beeps v2 thing is funny.

Nice kitty, Ed. :slight_smile: I actually wouldn’t have thought to try it for a good while longer, probably, except that I saw it was used in The Pizza Boy’s and Sephi-Hatu’s “Metroid 2: Remix.” I really liked the way it looked compared to a simple circle of light, so I figured I’d try it.

I’ve updated my source code to load a room I made in a hex editor (yeah, I seriously did it by hand–I also made some mistakes, it seems). Also, if anyone looked at or messed with the source code… Change the line “StretchAmnt = 1” to change the size of everything but the window itself. Also, did I mention you can change the shape of the glow? Well, unless you can edit 32bpp alpha bitmaps, you can’t, but I can. Could even use a grayscaled sprite for it. Haha.

New links:
EXE
VB6 Source

So I just spent a lot of time making a website for someone, and he wanted to use transparency for some things. I came up with two very neato (IMO) things to do with transparency, that are not yet supported by CSS, but which I haxed in with my awesomeness.
The first is a transparent gradient.
http://fat.koopa.googlepages.com/gradient.html
I use this as a cool-looking header. Keep in mind that the more table cells you add, the better the gradient looks. There are many variations, but right now, I have the leftmost 23% at 100% opacity, the rightmost 23% at 20% opacity, and 9 cells in the middle going down from 97 to 28% opacity, at 5% intervals. The code should be pretty easy to read, but feel free to ask if you have questions.
Keep in mind that, using this method, the header text has to be on a 100% solid background. It’s impossible to make a background translucent, but the text on it opaque.
Unless, of course you use the second thing I came up with =P
For this, you have to make two areas of the same size, and put them on top of each other. The text goes on top of the translucent background. The example here shows how to do this if they’re both in a table with a fixed width (% or px), and with a height equal to that of the text. This is easily adapted to a table with a fixed width and height (in % or px, doesn’t matter).
FF version: http://fat.koopa.googlepages.com/translucentbg.html (doesn’t work in Internet Explorer http://getfirefox.com/)
Here’s the same page with translucent text as well as background, for comparison:
http://fat.koopa.googlepages.com/translucentbgbad.html

This whole thing involves a number of FF versus IE quirks.
#1: the CSS code for transparency in FF is:
opacity: .##;
It’s a decimal, where 0 is transparent, and 1 is opaque.
in IE, the code is:
filter: alpha(opacity=##);
Here, it’s a percentage, with 100 for opaque, and 0 for transparent.
If you apply BOTH lines to one area, it will work fine in both IE and FF, and probably other browsers as well. Redundant, but it’s the only way.
EDIT: KINDOF. “filter: alpha(opacity=##);” inherits fine from to

in FF, as I just found out. Dunno how the hell that works. It works fine if you jam them both into one tag, though.

#2: for the second trick, IE works completely differently than FF. For one thing, IE can’t use a lot of CSS stuff on

tags, and it reads the “height:100%;” weirdly and different, and I just dunno. I’m working on an IE or cross-browser version as we speak.

Feel free to copy/paste my code if you want to use it.

EDIT: Keep in mind that I don’t know shizfizzle about proper HTML/CSS style, and my code is horrible. It gets the job done, but don’t use it as an example of anything but a cheap workaround for the two functions I described. There’s probably lots of excess code and bad formatting and whatnot.

EDIT2: Here is an IE version of the second trick:
http://fat.koopa.googlepages.com/translucentbgIE.html
This has really sloppy and stupid code, as you might expect from IE, and therefore doesn’t work in FF. Trying to think of a method that works for both…

EDIT3: Mother EFF. After a full day of trying to make a cross-browser version of the second trick, I found out that the last link (EDIT2) I posted doesn’t actually work. The box takes up twice as much space as it looks like it does (it takes up space about equal to itself below it, as you could see if you put a border around it). It works fine in FF. The difference is that the FF version uses two heights of 100%, and then puts them on top over each other, leaving 0%. The IE version uses two heights of 50%, and when those are put on top of each other, that leaves 50% below. No idea what to do about that.

Beepsv2 = awesome;

I figured out the Super Mario theme!
6412442144865641244214y65464164t41t564164t418641244564124989898y6544444564214444564444564216664681641q2yy229998y6421641q2yy22yyy654214

Yus.

It’s so fun to have the program running while I type. It sounds like R2-D2. :stuck_out_tongue:

Holy shit beeps rocks my life.
I can play the piano!!! (typing sounds hilarious XDDD)

Um, Tim. Take a look at your transparency pages…

Whoa. Holy shit. I’m not sure why…
EDIT: I sent them asking a message regarding why the eff. In the meantime, I’ll rehost them on another google account and change the links.
EDIT2: Er, I mean, I’ll do that on Sunday. I don’t have the pages here in Mass >_>
Hopefully no one (except troid) was too curious about that tidbit.

Well, I wanted to see…

…wow. I never have gotten into OpenGL/C++, etc. before, but this makes me want to REAL bad. =/

I didn’t actually code a program in C until last night. I made a window and a OpenGL context, with a rotating orange square. Looks like nothing special, but it’s a leap toward cross-platform compatibility! :sunglasses: (That’s a random experiment, by the way.)

EXE: http://www.geocities.com/christiankinesis/other/Doubt.zip

Source: http://www.geocities.com/christiankinesis/other/HiyaSrc.zip

…huh.
kinda curious why you threw in the mousewheel bit =P

Links updated. I realized maybe the use of a background hosted offsite might be bothering someone, who reported me to google, so I rehosted the pizza background >_>

I put in the mouse wheel thing because it’s not easy to do in Visual Basic (well, it is, but it requires an extra module and some hooking), but it goes along with what you have to do in C to get user input.

Haha, Beeps is awesome. You should add the ability to toggle spacebar-randomness off though; it screws up the flow of typing full sentence music.