Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Draw and Refresh faster


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-01-2007, 04:57 AM
Junior Member
 
Join Date: Jul 2007
Location: Hong Kong
Posts: 42
Send a message via MSN to hung Send a message via Yahoo to hung Send a message via Skype™ to hung
Default Draw and Refresh faster

To simulate a walking dog, I made use of forelayer and image lib (drawer) to erase last area then draw image on new position again. The transparency and partial refresh work fine.

However, the refresh speed is slow that I feel my the image is jumpping. Any way to draw image and refresh faster?

I am using Dopod D810 WM6, CPU Samsung (R) 2442 with 400Mhz. The timer interval is set to 1 already.

Thanks in advance..
__________________
Yours,

Dopod D810 WM6 GPS HSDPA 3G Wifi Bluetooth
Reply With Quote
  #2 (permalink)  
Old 08-01-2007, 06:27 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,132
Default

Can you post your code?
Reply With Quote
  #3 (permalink)  
Old 08-01-2007, 08:51 AM
Junior Member
 
Join Date: Jul 2007
Location: Hong Kong
Posts: 42
Send a message via MSN to hung Send a message via Yahoo to hung Send a message via Skype™ to hung
Default

Attached the little lengthy code. I used image and form lib.

It is fast enough when run on PC but slow on PPC.

Here is the key code:

sub repaint

' handle mapwin move
if mapwin.moved = 1 then

'erase all sp
for ii = 0 to spcnt - 1
sphide(ii)
next

' redraw mapwin
mapwin.x = min(bmpmap.Width - mapwin.w, max(0, mapwin.x + mapwin.dx) )
mapwin.y = min(bmpmap.Height - mapwin.h, max(0, mapwin.y + mapwin.dy) )
rectsrc.x = mapwin.x
rectsrc.Y = mapwin.y
rectsrc.Width = mapwin.w
rectsrc.Height = mapwin.h
rectdst.X = mapscr.x
rectdst.y = mapscr.y
rectdst.width = mapscr.w
rectdst.height = mapscr.h
drawerb.DrawImage1(bmpmap.Value, rectsrc.Value, rectdst.Value, true)
drawerb.Refresh2(rectdst.Value)

mapwin.moved = 0
mapwin.dx = 0
mapwin.dy = 0

form1.Line(10, 10, 60, 60, cRed, B)

for ii = 0 to spcnt - 1
spshow(ii)
next

end if
' handle sp move
for ii = 0 to spcnt - 1
if spmap(ii).moved = 1 and ii <> spselected then
spmove(ii)
end if
next
end sub


sub spshow(nsp)
if spinwin(nsp) then
rectsrcs.X = 50 * spmap(nsp).pg
rectsrcs.Y = 0
rectsrcs.Width = spmap(nsp).w
rectsrcs.Height = spmap(nsp).h

rectdsts.X = scrx(spmap(nsp).x)
rectdsts.Y = scry(spmap(nsp).y)
rectdsts.Width = spmap(nsp).w
rectdsts.Height = spmap(nsp).h

drawerf.DrawImage1(bmpsprite.Value, rectsrcs.Value, rectdsts.Value, true)
drawerf.Refresh2(rectdsts.Value)

end if
end sub

sub sphide(nsp)
'erase original image on screen
rectdsts.X = scrx(spmap(nsp).x)
rectdsts.Y = scry(spmap(nsp).y)
rectdsts.Width = spmap(nsp).w
rectdsts.Height = spmap(nsp).h
drawerf.fillrectangle(brushs.Value, rectdsts.Value) ' clear last sprite pos
drawerf.Refresh2(rectdsts.Value)

end sub


sub spmove(nsp) ' always move towards x + dx, y + dy
'erase original image on screen
sphide(nsp)

'move to new pos on bmpmap
spmap(nsp).x = min(bmpmap.Width - spmap(nsp).w, max(0, spmap(nsp).x + spmap(nsp).dx))
spmap(nsp).y = min(bmpmap.Height - spmap(nsp).h, max(0, spmap(nsp).y + spmap(nsp).dy))
' draw sp again
spshow(nsp)

spmap(nsp).moved = 0
spmap(nsp).dx = 0
spmap(nsp).dy = 0

if ptinrect(spmap(nsp).x, spmap(nsp).y, 10, 10, 60, 60) then
if spmap(nsp).acc = 0 then spslide(nsp)
end if

end sub
Attached Files
File Type: zip testsprite.zip (78.0 KB, 13 views)
__________________
Yours,

Dopod D810 WM6 GPS HSDPA 3G Wifi Bluetooth
Reply With Quote
  #4 (permalink)  
Old 08-01-2007, 02:00 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,132
Default

You can see this example for a simple moving image: http://www.basic4ppc.com/files/BouncingSmiley.zip
This example runs pretty smooth, however moving more images will be slower (like in your case).
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bad screen refresh with sound command pmu5757 Questions & Help Needed 6 05-09-2008 09:53 PM
Creating code faster pmu5757 Basic4ppc Wishlist 0 04-13-2008 12:33 PM
How to draw into a Panel? BasicUser Questions & Help Needed 1 07-21-2007 07:28 AM
Help/tips to make this app run faster J12345T Questions & Help Needed 3 07-10-2007 12:06 AM
No refresh on device rosmalen Bug Reports 5 06-16-2007 10:10 PM


All times are GMT. The time now is 01:14 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0