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.


'sprite' dragging (made progress but have new problems)


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-05-2008, 06:50 PM
Junior Member
 
Join Date: Feb 2008
Posts: 17
Default 'sprite' dragging (made progress but have new problems)

I was wondering whether someone who is better at basic4ppc than I could take a look at my code and tell me where I'm going wrong!

The attached project works on my desktop but has the following problems on my PPC:

a) the subroutine:

Sub hk_HardKeyPressed

Select hk.KeyPressed
Case hk.KeyEnter:
AppClose
End Select

End Sub

does not function as expected (i.e. to end the program). I am sure this is something very simple but I have the exact same subroutine in another program and it works fine!

b) The screen does not display properly on my PPC. This is probably due to the method I am using, which as is follows
1. in App_Start, I use formMain.DrawImage to draw a permanent background image onto the backlayer of formMain
2. then, every timer tick, I erase the entire forelayer of formMain and use formMain.fDrawImage to draw the appropriate icons onto it

The reason I want to draw the screen this way (rather than use Sprites) is so that the icons can be dragged around smoothly using the touch screen (currently they are constrained so they can only be dragged 2 hexes straight up). I realise that erasing and then re-drawing the entire forelayer every time is inefficient but that is something I can look at later.

Any ideas?
Attached Files
File Type: zip space.zip (62.1 KB, 15 views)
Reply With Quote
  #2 (permalink)  
Old 03-05-2008, 07:44 PM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 486
Awards Showcase
Beta Tester 
Total Awards: 1
Default

I'm still looking through your code, however the reason for the hardkeys not working is because you've overlooked creating a new instance in app_start.
Just add hk.new1("form1",true,true,true) and you'll be up and running again.
Will get back to you about the display problem when I suss out what happening.

Regards,
RandomCoder
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #3 (permalink)  
Old 03-05-2008, 10:00 PM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 486
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Attached is a modified code that will hopefully get you moving forward again.
It's not complete as I somewhat struggled to understand exaclty what was happening with the maths.
Basically I'm approaching the problem by storing the last x and y of the icon so that when it moves the previous position can be erased.
Some of your code is duplicated such as creating a new instance of drawer etc, you only need do this the once.
Hope this is enough to help you see a way forward.

Regards,
RandomCoder
Attached Files
File Type: sbp space_mod.sbp (7.5 KB, 6 views)
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #4 (permalink)  
Old 03-06-2008, 11:39 AM
Junior Member
 
Join Date: Feb 2008
Posts: 17
Default

Thank you very much for having a look at my code!
It seems that the display problems on the PPC were caused by refreshing the entire form at every timer tick which was obviously more than it could handle. I will continue with the method you have implemented - it looks like a good solution. It is certainly more efficient and much less flickery.

There still seems to be an issue with the display on the PPC though - transparency. It works fine on the desktop, but what should be transparent shows up black on the PPC. Something to worry about later though perhaps. Thanks again for your help.
Reply With Quote
  #5 (permalink)  
Old 03-06-2008, 12:29 PM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 486
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Yes I saw the problem last night but thought that there must be a way around it.
Anyway, I seem to recall this issue being raised before - and here it is.... image transparent
Hopefully this will solve your problem although it looks like it is a little convoluted.

Basically I think that the idea is to draw the image and store its position. Then redraw in a new position, repaint the background using the stored (last position values) and store the new position again etc.

I noticed that you were redrawing all three icons each time. Ideally you only want to redraw the items that have changed. This will significantly improve the speed of operation as only small changes will be being made each cycle.

Regards,
RandomCoder
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #6 (permalink)  
Old 03-06-2008, 01:51 PM
Junior Member
 
Join Date: Feb 2008
Posts: 17
Default

Success!

Thanks for that forum link, it was very helpful. It seems the key is not to use the forelayer at all but draw entirely on the backlayer.
I implemented another bitmap as a buffer (as you suggested) to keep track of what has to be redrawn under the icon that is moving. This works great.
The code needs a lot of cleaning up, and there are still some issues that need to be addressed (such as: still doesn't work properly on PPC), but I am well on my way now.

I have attached my code in case you want to see what I have done.
Attached Files
File Type: sbp space_mod2.sbp (9.0 KB, 9 views)
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
Two new Twitter apps. made with Basic4ppc bluedude Share Your Creations 1 05-06-2008 02:12 PM
Sprite problems willisgt Questions & Help Needed 2 02-28-2008 06:30 PM
Low-level FTP upload with progress brathbone Open Source Projects 3 02-10-2008 12:42 PM
Progress bar on FTP download willisgt Questions & Help Needed 16 01-28-2008 05:22 PM
Vertical Progress bar davelew1s Questions & Help Needed 2 08-23-2007 07:09 PM


All times are GMT. The time now is 04:01 AM.


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