Author Topic: Game slow on gp2x F200  (Read 2780 times)

Offline bricky91

  • Mc. Print
  • *
  • Posts: 47
    • View Profile
Game slow on gp2x F200
« on: 2010-Feb-10 »
Hey guys! I have a problem. I'm currently using GL Basic 7.250 and on my gp2x F200 the game I'm making runs very very slow, but I don't know why! Here's the code I wrote, just in case:

Code: (glbasic) [Select]
SETSCREEN 320, 240, FALSE

//------------------------------------------------------
//----------------------RISORSE-------------------------
//------------------------------------------------------
LOADSPRITE "sprites/sp_block-mondo1_sopra.png", 0
LOADSPRITE "sprites/sp_block_mondo1_sotto.png", 1



//------------------------------------------------------
//----------------------VARIABILI-----------------------
//------------------------------------------------------
GLOBAL mx, my, b1, b2
GLOBAL stato_gioco, stato_livello, stato_menu


GLOBAL map_w, map_h
GLOBAL map[], map_red[] //map_red[x][y]=1 -> non si può mettere nulla (nell'editor chiaraente)
GLOBAL ed_item[], ed_item_num, ed_item_timer
GLOBAL scroll_x, scroll_y


//------------------------------------------------------
//----------------------COSTANTI------------------------
//------------------------------------------------------
GLOBAL KEY_RIGHT=205
GLOBAL KEY_LEFT=203
GLOBAL KEY_UP=200
GLOBAL KEY_DOWN=208
GLOBAL KEY_ENTER=28
GLOBAL KEY_SHIFT_DX=54
GLOBAL KEY_SHIFT_SX=42
GLOBAL KEY_TAB=15
GLOBAL KEY_PAGE_UP=201
GLOBAL KEY_PAGE_DOWN=209
GLOBAL KEY_ESC=1

GLOBAL T_SIZE=20
GLOBAL ED_ITEM_MAX=5



DIM ed_item[ED_ITEM_MAX]
DIM map[32][24]
DIM map_red[32][24]




//provvisori------------------
stato_gioco=2
ed_item_num=0
scroll_x=0
scroll_y=0
map_w=32
map_h=24



//------------------------------------------------------
//----------------------MAN LOOP------------------------
//------------------------------------------------------
WHILE stato_gioco<>-1
SELECT stato_gioco
CASE 0 //menu, scelta livello, settaggio editor, carica livello da editor
GOSUB scegli_menu
CASE 1 //gioco vero e proprio
GOSUB ingame
CASE 2 //editor
GOSUB editor
ENDSELECT
SHOWSCREEN
WEND
END





// ------------------------------------------------------------- //
// ---  SCEGLI_MENU  ---
// ------------------------------------------------------------- //
SUB scegli_menu:



ENDSUB // SCEGLI_MENU




// ------------------------------------------------------------- //
// ---  INGAME  ---
// ------------------------------------------------------------- //
SUB ingame:



ENDSUB // INGAME




// ------------------------------------------------------------- //
// ---  EDITOR  ---
// ------------------------------------------------------------- //
SUB editor:


// disegno delle robe dell'edior tipo linee guida e spazi rossi---------------------------------------------
DRAWRECT 0, 0, map_w*T_SIZE, map_h*T_SIZE, RGB(255, 255, 255)

FOR x=0 TO map_w-1
FOR y=0 TO map_h-1
IF map[x][y]=0 //quadratini rossi-> non ci si può piazzare sopra oggetti!
IF y<24-1
IF map[x][y+1]<>map_h-1
DRAWRECT x*T_SIZE-scroll_x, y*T_SIZE-scroll_y, T_SIZE, T_SIZE, RGB(255, 0, 0)
ENDIF
ELSE
DRAWRECT x*T_SIZE-scroll_x, y*T_SIZE-scroll_y, T_SIZE, T_SIZE, RGB(255, 0, 0)
ENDIF
ENDIF


DRAWLINE x*T_SIZE-scroll_x, 0-scroll_y, x*T_SIZE-scroll_x, map_h*T_SIZE-scroll_y, RGB(128, 128, 128) //linee per i quadrati
DRAWLINE x*T_SIZE-1-scroll_x, 0-scroll_y, x*T_SIZE-1-scroll_x, map_h*T_SIZE-scroll_y, RGB(128, 128, 128)
DRAWLINE 0-scroll_x, y*T_SIZE-scroll_y, map_w*T_SIZE-scroll_x, y*T_SIZE-scroll_y, RGB(128, 128, 128)
DRAWLINE 0-scroll_x, y*T_SIZE-1-scroll_y, map_w*T_SIZE-scroll_x, y*T_SIZE-1-scroll_y, RGB(128, 128, 128)
NEXT
NEXT



//fai scorrere gli oggetti dell'editor------------------------------------------------------------------------
IF ed_item_timer>0
DEC ed_item_timer, 1
ELSE
IF KEY(KEY_SHIFT_DX)
IF ed_item_num<ED_ITEM_MAX THEN INC ed_item_num, 1
ed_item_timer=10
ELSEIF KEY(KEY_SHIFT_SX)
IF ed_item_num>0 THEN DEC ed_item_num, 1
ed_item_timer=10
ENDIF
ENDIF



//scrlling----------------------------------------------------------------------------------------------------
IF KEY(KEY_RIGHT)
IF scroll_x<(map_w/2-1)*T_SIZE
INC scroll_x, 4
ELSE
scroll_x=(map_w/2-1)*T_SIZE
ENDIF
ENDIF


ENDSUB // EDITOR

Hwever, I don't think the problem can be realted to the code... Any ideas?

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4158
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Game slow on gp2x F200
« Reply #1 on: 2010-Feb-10 »
Can you provide the sprites so that we can easily see where the problem lies? I own two GP2Xs and a Wiz, so I can test this properly.

Right, I've tested it on an F200 and added a FPS counter and I get around 4FPS on GP2X as apposed to 60FPS on pc. There is something very wrong here.

[PLAYED AROUND A BIT]
You can get the speed back by removing the DRAWLINE commands in the EDITOR function (replacing with sprites shouldn't be too costly, speedwise).

Without going any further the problem appears to be solved - however due to language problems I can't understand all of your code, or what it's supposed to be doing.
« Last Edit: 2010-Feb-10 by Ian Price »
I came. I saw. I played.

Offline bricky91

  • Mc. Print
  • *
  • Posts: 47
    • View Profile
Re: Game slow on gp2x F200
« Reply #2 on: 2010-Feb-10 »
Well, as you can see I don't draw any spirte in the game yet. And the game runs slowly even if I don't load them. So I don't think sprites can be the problem at all. Could you test the code (even without sprites, because as I said on my gp2x the game runs slowly even if I don't draw or load any sprite) on your gp2x just to see if it's a problem related to my console?

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4158
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Game slow on gp2x F200
« Reply #3 on: 2010-Feb-10 »
See my updated post - I was testing and typing before you replied.
I came. I saw. I played.

Offline bricky91

  • Mc. Print
  • *
  • Posts: 47
    • View Profile
Re: Game slow on gp2x F200
« Reply #4 on: 2010-Feb-10 »
Oh, thank you very much! By the way, very stange, because in GL Basic 6 DRAWLINE worked well also on gp2x, I never had any probem. I wrote this same game on version 6 and it worked well (I am now re-writing it).

Offline bricky91

  • Mc. Print
  • *
  • Posts: 47
    • View Profile
Re: Game slow on gp2x F200
« Reply #5 on: 2010-Feb-10 »
I solved the first problem, but there is another one. If I draw a sprite it works well, but the problem is that the program draws also the parts in color (255, 0, 128) in stead of making them transparent. I just load the sprite (.png file) and draw it with the command DRAWSPRITE as I always did. What's the problem this time?

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4158
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Game slow on gp2x F200
« Reply #6 on: 2010-Feb-10 »
Have you created the sprite with MS Paint on Windows7 or Vista?

Is it a .PNG image?

If yes the reason is simple - it's a 32bit .PNG and GLB requires the .PNG to be in 24Bit (max). I had this problem when I upgraded to Windows7. My solution? Grab MSPaint from XP or 98 and put it onto your machine and use that instead. Or use a different paint program.

If all (or at least some) of that is incorrect, then I don't know. post the image and we'll get to the bottom of it quickly i'm sure.
I came. I saw. I played.

Offline bricky91

  • Mc. Print
  • *
  • Posts: 47
    • View Profile
Re: Game slow on gp2x F200
« Reply #7 on: 2010-Feb-10 »
I have win xp, but I create the sprites with game maker 8 (which has a useful and simple sprite editor) and I noticed that it creates a 32bit image. So, problem probably solved! Thanks very much!  :good:

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10745
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Game slow on gp2x F200
« Reply #8 on: 2010-Feb-11 »
32 bit png should work. If not, please send me one that's broken :/

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4158
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Game slow on gp2x F200
« Reply #9 on: 2010-Feb-11 »
Nope. This doesn't work Gernot - see the attached 32bit PNG created with MSPaint in Windows 7 (as I mentioned before Christmas). The magenta colour is definitely RGB(255,0,128) - it was when i first drew it and when checked with MSPaint XP it still is.

[attachment deleted by admin]
I came. I saw. I played.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10745
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Game slow on gp2x F200
« Reply #10 on: 2010-Feb-11 »
Ah, yes.
The problem i, a 32 bit png image does have an 8 bit alpha channel. Thus, I use that channel to get the transparency out. (Much better for partial alpha blended images, see the glow in the title logo: http://www.youtube.com/watch?v=DQ9g-R4lv8w )

This one, however, has 32 bits, but alpha is all opaque. Thx MS :/

So, we're both right I guess ;)

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4158
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Game slow on gp2x F200
« Reply #11 on: 2010-Feb-11 »
Told ya! :P
I came. I saw. I played.