Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

How to create sprite/ moving figures?

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-16-2007, 06:53 PM
Basic4ppc Veteran
 
Join Date: Apr 2007
Posts: 269
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, 06:56 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Can You please define "sprite" to me?
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
Reply With Quote
  #3 (permalink)  
Old 05-16-2007, 06:59 PM
Basic4ppc Veteran
 
Join Date: Apr 2007
Posts: 269
Default

Well, anything that moves, from created images to balls, figurines, animations etc
Reply With Quote
  #4 (permalink)  
Old 05-16-2007, 07:12 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,733
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
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, 07:14 PM
Basic4ppc Veteran
 
Join Date: Apr 2007
Posts: 269
Default

How do I address the two different forelayers?
Reply With Quote
  #6 (permalink)  
Old 05-16-2007, 07:29 PM
RandomCoder's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire, UK
Posts: 623
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
__________________
"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #7 (permalink)  
Old 05-16-2007, 08:57 PM
Basic4ppc Veteran
 
Join Date: Apr 2007
Posts: 269
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, 09:39 PM
RandomCoder's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire, UK
Posts: 623
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
__________________
"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #9 (permalink)  
Old 05-17-2007, 08:38 AM
Basic4ppc Veteran
 
Join Date: Apr 2007
Posts: 269
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, 11:42 AM
RandomCoder's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire, UK
Posts: 623
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
__________________
"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 Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Drawing and moving a Character Transparently (Not a Sprite) Drewpeu Questions (Windows Mobile) 2 10-08-2008 03:15 PM
Diff GPS values without moving GPS mouse Georg Questions (Windows Mobile) 1 04-22-2008 06:58 AM
moving a sprite? colin9876 Questions (Windows Mobile) 7 11-27-2007 04: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 07:21 AM
Error when moving treeview to a tabcontrol Peter Questions (Windows Mobile) 2 05-15-2007 06:36 AM


All times are GMT. The time now is 08:50 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0