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.


How to create sprite/ moving figures?


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-16-2007, 07:53 PM
Basic4ppc Veteran
 
Join Date: Apr 2007
Posts: 200
Default How to create sprite/ moving figures?

Hi,

Is there a way to create a sprite or a moving figure? I want to make a game in which things are moving against a background.
thnx for your input!
Marc
Reply With Quote
  #2 (permalink)  
Old 05-16-2007, 07:56 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,343
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Can You please define "sprite" to me?
__________________
Paulo Gomes
Porto, Portugal

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD

DLL Version Listing
Reply With Quote
  #3 (permalink)  
Old 05-16-2007, 07:59 PM
Basic4ppc Veteran
 
Join Date: Apr 2007
Posts: 200
Default

Well, anything that moves, from created images to balls, figurines, animations etc
Reply With Quote
  #4 (permalink)  
Old 05-16-2007, 08:12 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,199
Default

You can use the ForeLayer property of a form and draw the moving images on the fore layer.
On the background you can put an image too.
You will need to handle the movement.
It should be done using a Timer.
Reply With Quote
  #5 (permalink)  
Old 05-16-2007, 08:14 PM
Basic4ppc Veteran
 
Join Date: Apr 2007
Posts: 200
Default

How do I address the two different forelayers?
Reply With Quote
  #6 (permalink)  
Old 05-16-2007, 08:29 PM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 486
Awards Showcase
Beta Tester 
Total Awards: 1
Default

You can use FDrawImage, but to make the image appear to move you will need to erase the area that the last image occupied before redrawing in a slightly different place.

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
  #7 (permalink)  
Old 05-16-2007, 09:57 PM
Basic4ppc Veteran
 
Join Date: Apr 2007
Posts: 200
Default

But if I use Erase won't I erase the Forelayer underneath? I'd like to address the 2 forelayers separately. Is that possible?
Marc
Reply With Quote
  #8 (permalink)  
Old 05-16-2007, 10:39 PM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 486
Awards Showcase
Beta Tester 
Total Awards: 1
Default

You can use the normal (background) Form layer using DrawImage and then apply a separate image to the Forms forelayer using the FDrawImage command. Finally you can erase part or all of the forelayer using FErase before moving the image. Another useful aspect to using the forelayer is that it supports transparency so you can select a particular colour not to display on the forelayer.

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
  #9 (permalink)  
Old 05-17-2007, 09:38 AM
Basic4ppc Veteran
 
Join Date: Apr 2007
Posts: 200
Default

OK, thnx, that explains it. Is there, by any chance, an example of the "famous" bouncing ball in code around to see this in action?
Marc
Reply With Quote
  #10 (permalink)  
Old 05-17-2007, 12:42 PM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 486
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Stellaferox,

I'm not familiar with the 'famous' boucing ball but here's a little somthing I knocked up whist having my dinner at work -
Code:
Sub Globals
Height=100: LastHeight=100: Direction=5
End Sub

Sub App_Start
	Form1.Show
	Form1.Line(0,200,Form1.Width,200,cBlack)
	Form1.ForeLayer=True
	BounceBall
	Timer1.Enabled=True
End Sub

Sub BounceBall
	Form1.FCircle(Form1.Width/2,100,5,cRed,F)
	LastHeight=100
End Sub


Sub Timer1_Tick
	Height=LastHeight+Direction
	Form1.FErase(Form1.Width/2-5,LastHeight-5,Form1.Width/2+5,LastHeight+5)
	Form1.FCircle(Form1.Width/2,Height,5,cRed,F)
	LastHeight=Height
	If Height=195 Then Direction=-5
	If Height=100 Then Direction=5
End Sub
It's a never ending bouncing ball and the code needs some polishing up but at least it gives you the idea. I'm sure that you could gradually make the bounces smaller until finally coming to a stop and turn the timer off.

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
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
Drawing and moving a Character Transparently (Not a Sprite) Drewpeu Questions & Help Needed 2 10-08-2008 04:15 PM
Diff GPS values without moving GPS mouse Georg Questions & Help Needed 1 04-22-2008 07:58 AM
moving a sprite? colin9876 Questions & Help Needed 7 11-27-2007 05:10 PM
XYCalc -graphs an equation or editable table of figures in regular, bar or pie chart HarleyM Code Samples & Tips 2 11-24-2007 08:21 AM
Error when moving treeview to a tabcontrol Peter Questions & Help Needed 2 05-15-2007 07:36 AM


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


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