This code

Non-platform specific questions.

This code

Postby segwego12 » Fri Sep 26, 2008 2:10 am

I'm trying to make a plasma effect, what should I do to this code so Game Editor can handle it?
Code: Select all
int main(int argc, char *argv[])
{
    screen(256, 256, 0, "Plasma");

    for(int x = 0; x < w; x++)
    for(int y = 0; y < h; y++)
    {
        int color = int(128.0 + (128.0 * sin(x / 8.0)));
        pset(x, y, ColorRGB(color, color, color));
    }
    redraw();
    sleep();
    return(0);
}
http://www.freewebs.com/primewaregames/

The Primeware Games website

Projects
Era of Rome: Done
segwego12
 
Posts: 167
Joined: Mon Jul 07, 2008 2:48 am
Location: My Website, please come to my website.
Score: 3 Give a positive score

Re: This code

Postby segwego12 » Fri Sep 26, 2008 12:31 pm

hello?
http://www.freewebs.com/primewaregames/

The Primeware Games website

Projects
Era of Rome: Done
segwego12
 
Posts: 167
Joined: Mon Jul 07, 2008 2:48 am
Location: My Website, please come to my website.
Score: 3 Give a positive score

Re: This code

Postby Spidy » Fri Sep 26, 2008 3:17 pm

maybe makslane will help ya
Image
VOTE FOR MY SIGNATURE PLEASE.......THANK YOU
User avatar
Spidy
 
Posts: 935
Joined: Tue Aug 14, 2007 1:28 pm
Location: http://www.inatonibai.com
Score: 38 Give a positive score

Re: This code

Postby segwego12 » Fri Sep 26, 2008 4:43 pm

ok.
http://www.freewebs.com/primewaregames/

The Primeware Games website

Projects
Era of Rome: Done
segwego12
 
Posts: 167
Joined: Mon Jul 07, 2008 2:48 am
Location: My Website, please come to my website.
Score: 3 Give a positive score

Re: This code

Postby makslane » Sat Sep 27, 2008 1:01 am

1) Create a canvas actor
2) In the 'Draw Actor' event of the canvas, put the code:

Code: Select all
int x1, y1;

for(x1 = 0; x1 < width; x1++)
{
    for(y1 = 0; y1 < height; y1++)
    {
        int color = 128.0 + (128.0 * sin(x1 / 8.0));
 
        setpen(color, color, color, 0, 1);
        putpixel(x1, y1);
    }
}


The result will be:
Attachments
plasma1.jpg
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Re: This code

Postby makslane » Sat Sep 27, 2008 1:08 am

With little changes, we ca have other patterns:

Code: Select all
int x1, y1;


for(x1 = 0; x1 < width; x1++)
{
    for(y1 = 0; y1 < height; y1++)
    {
        int color = 128.0 + (128.0 * sin(x1*y1/32.0));
 
        setpen(color, color, color, 0, 1);
        putpixel(x1, y1);
    }
}
Attachments
plasma2.jpg
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Re: This code

Postby makslane » Sat Sep 27, 2008 1:21 am

Now, an animated color effect:

Code: Select all
int x1, y1;

for(x1 = 0; x1 < width; x1++)
{
    for(y1 = 0; y1 < height; y1++)
    {
        int red = 128.0 + (128 * sin((1/(float)frame)*x1*y1/10.0));
        int green = 128.0 + (128 * sin((1/(float)frame)*x1*y1/5.0));
        int blue = 128.0 + (128 * sin((1/(float)frame)*x1*y1/2.0));
 
        setpen(red, green, blue, 0, 1);
        putpixel(x1, y1);
    }
}


plasma3.jpg


And the ged file
plasma.zip
(1 KiB) Downloaded 95 times
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Re: This code

Postby segwego12 » Sat Sep 27, 2008 2:06 am

makslane wrote:Now, an animated color effect:

Code: Select all
int x1, y1;

for(x1 = 0; x1 < width; x1++)
{
    for(y1 = 0; y1 < height; y1++)
    {
        int red = 128.0 + (128 * sin((1/(float)frame)*x1*y1/10.0));
        int green = 128.0 + (128 * sin((1/(float)frame)*x1*y1/5.0));
        int blue = 128.0 + (128 * sin((1/(float)frame)*x1*y1/2.0));
 
        setpen(red, green, blue, 0, 1);
        putpixel(x1, y1);
    }
}


plasma3.jpg


And the ged file
plasma.zip

Thank you makslane, Now, when can I learn to make fire?
http://www.freewebs.com/primewaregames/

The Primeware Games website

Projects
Era of Rome: Done
segwego12
 
Posts: 167
Joined: Mon Jul 07, 2008 2:48 am
Location: My Website, please come to my website.
Score: 3 Give a positive score

Re: This code

Postby edh » Sat Sep 27, 2008 8:09 pm

+1 point for makslane, this is something new I learned.
User avatar
edh
 
Posts: 233
Joined: Thu Sep 13, 2007 12:17 am
Location: Maine, USA
Score: 14 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron