Page 2 of 4

Re: Ideas for Optimization

PostPosted: Thu Sep 03, 2009 5:16 pm
by OmniArts
I see what u mean, but the arena's seating area and fighting area are all the one image. But.. what if i were to split it into several smaller images?

Re: Ideas for Optimization

PostPosted: Thu Sep 03, 2009 5:54 pm
by Hblade
In that case, arena.x+width of seats :D Say, the distance of the seats is 300 pixels then it goes to the arena, you'd use arena.x+300, find out how much the distance is by using the gimp and zooming in :D

Re: Ideas for Optimization

PostPosted: Fri Sep 04, 2009 1:28 am
by cforall
~~~Gimp vs Photoshop again~~~
hehe Thx for letting me know the Gimp Hblade +1P!

there is something else I want to say
I find GE locate a image based on the image center~
just look at these 2 images, add them to a actor as Mulitple Files you will find the dwarf is still~
So....you can cut off those transparent pixel , just make sure the center match~~~

the size of dwarf_attack3_001.png is 195X172
the 172 is a even num so I can easily change it to 86, but the 195 is a odd num so not easy to change .
the size of dwarf_attack3_002.png is 195X86
I don't know if I make myself clear~~ :mrgreen: :mrgreen: :mrgreen:

Re: Ideas for Optimization

PostPosted: Fri Sep 04, 2009 1:48 am
by Hblade
Hey yeah :D Optimizing the size too, nice job cforall :D

Re: Ideas for Optimization

PostPosted: Mon Sep 07, 2009 1:51 am
by OmniArts
ah, i see, thanks for your help
So no matter what size i cut the image.. as long as the center remains the same it should align properly in GE?

I think I'll make a script in Photoshop tonight.. there's a lot of images so it may take a while to complete!

Re: Ideas for Optimization

PostPosted: Fri Sep 11, 2009 4:26 am
by OmniArts
Well Ive been optimizing more images, but for my background image GE is trying to make it transparent, causing all sorts of black glitches throughout the image.
I thought it was image editor for a while until i realised it was GE itself.

Is there any way of turning this feature off?

Re: Ideas for Optimization

PostPosted: Fri Sep 11, 2009 5:04 am
by Hblade
yes there is, simply open the image in the gimp, right click it, then select "Add Alpha Channel" then save it again.

Re: Ideas for Optimization

PostPosted: Sat Sep 12, 2009 1:48 am
by cforall
Yes Hblade , add a Alpha Channel could solve this but in the some time turn your image into a big PNG32

GIF/JPG/PNG8/PNG24 cannot own a 8-bit Alpha Channel
PNG32 = PNG24 + 8-bit Alpha Channel = 8-bit Red + 8-bit Green + 8-bit Blue + 8-bit Alpha...

So if you use GIF/JPG/PNG8/PNG24 you can't add a 8-bit Channel

Notes:
- If the image file has a color depth lower than 32 bits, Game Editor understands that the color of the first pixel (upper left corner) is the color that should become totally transparent in the image.
- If your image has 32 bits color depth, Game Editor will consider the alpha channel (transparency channel) of the image.
- If your image is a gif, Game Editor will consider the gif transparent color.
- If all pixels in the image have the same color (solid image) the image will be consider solid.


there is a way, not smart
change the upper left corner pixel to a special color that don't exist in the rest of the image
like pure red (255,0,0) pure green (0,255,0) .......
but this will make the image bigger because you add a new color to it
:D :D :D :D :D :D :D

Re: Ideas for Optimization

PostPosted: Sat Sep 12, 2009 2:31 am
by cforall
about PNG :
http://en.wikipedia.org/wiki/Portable_Network_Graphics
Wikipedia is always helpful :D

Re: Ideas for Optimization

PostPosted: Sun Sep 13, 2009 5:19 am
by OmniArts
thanks for the info, I can spare adding one more color to it, as there is only 1 background image to be used.

Re: Ideas for Optimization

PostPosted: Sun Sep 13, 2009 10:14 pm
by Fuzzy
Hblade wrote:Theres another way to stay inside the arena. ok, what ever key moves your character, say... left, you'd say, if (x>areana.x) { x = x - 4; } this would make the character move left ONLY when he's in the arena, when he reaches the arena's X he stops moving :D


I am not crazy about this trick. It would take four ifs to limit all the directions.

You know the total width of the arena, so store that in a var. You know the start point of the arena on the left side, so store that too(the edge of the seats, right?)

Now you just need to clamp(constrain) the value of x to be leftside+xwidth. Here is how you do it.

Lets say the seats are 60 pixels wide. The arena is 300 pixels wide, after the seats, to the next seats. and you are stepping -4 pixels to the left.
Code: Select all
// global code]
int leftSeats = 60;
int ArenaXsize = 300;
int walkSpeed = 4;
StepLeft -= walkSpeed;
StepRight += walkSpeed;


Code: Select all
// in left key press perhaps?
x += StepLeft;


Code: Select all
// in right key press perhaps?
x += StepRight;


Code: Select all
// in draw, likely.
x = max(leftSeats, min(x, ArenaXsize));


This will add or subtract 4 points from x. Then it will perform the min section first, setting x to equal which ever is smaller, x or arena size(these are always the larger numbers). That means that if you are out of bounds on the right side, it will put you back in the arena. Then if you are trying to step too far left, the max statement sets x to the maximum of leftSeats and the previous results.

No matter which way you are walking, you will be clamped to the area of the arena. Do this with up/down as well.

Having the step sizes in global code means you dont have to track those variables down in every place you move. For example, if you change walking speed.

Can someone explain this a little more clearly if I havent?

Re: Ideas for Optimization

PostPosted: Mon Sep 14, 2009 8:18 pm
by Bee-Ant
Why dont you just type 60 instead of leftSeats?it needs a checking as well right?(its okay if there are more use of leftSeats,but in this case...)
And
stepLeft+=walkSpeed;
stepRight-=walkSpeed;
In global code doesnt make sense...
Wouldnt them to be continuesly increased or decreased?
Why didnt you put them in the keydown?

Anyway, using your method need a deep thinking (dont treat idiot like me as smart as you) and more than 4 lines of code. I think using IF is the simpler way :P
Well,your code suits to finishing project i think,in the starting,basic code its okay since you have a lot work to do :D

Re: Ideas for Optimization

PostPosted: Mon Sep 14, 2009 10:43 pm
by Fuzzy
Bee-Ant wrote:Why dont you just type 60 instead of leftSeats?it needs a checking as well right?(its okay if there are more use of leftSeats,but in this case...)
And
stepLeft+=walkSpeed;
stepRight-=walkSpeed;
In global code doesnt make sense...
Wouldnt them to be continuesly increased or decreased?
Why didnt you put them in the keydown?

Anyway, using your method need a deep thinking (dont treat idiot like me as smart as you) and more than 4 lines of code. I think using IF is the simpler way :P
Well,your code suits to finishing project i think,in the starting,basic code its okay since you have a lot work to do :D


I'll never think you are an idiot my friend.

Global code only happens once, so that will not add walkSpeed over and over.

Part of the reason that I used leftSeats instead of 60 is to illustrate what the numbers are. Also, it makes it easier to find if you need to change it. Also, it doesnt hurt to have extra variables.

It is easier to make a game more complicated as you go. Making a complicated game more simple is harder. Starting with less ifs means you have less stuff to check for bugs. Its like in school, you dont want to use extra words for an essay, right? If is more complicated than variable declaration.

Re: Ideas for Optimization

PostPosted: Tue Sep 15, 2009 5:30 pm
by Bee-Ant
Thats why i said it needs a deep thinking. For starting,using basic code is okay i think. Then when the project is nearly finished,just edit code to that simpler one. :D
Just my opinion :P

Re: Ideas for Optimization

PostPosted: Tue Sep 15, 2009 5:30 pm
by Bee-Ant
Thats why i said it needs a deep thinking. For starting,using basic code is okay i think. Then when the project is nearly finished,just edit code to that simpler one. :D
Just my opinion :P