473,386 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

when scrolling a form vertically the "y" coords of a picturebox are reset!

Hi,

I am writing a small game that is using a form 800 * 600. The form
can be scrolled vertically up to a height of 1200 (basically the form
can be scrolled down one screen vertically).

The user controls a picturebox (my sprite) with the cursor keys

When the sprite hits the y value of 600 the screen scrolls down to
display the bottom part of the screen (by focusing on a hidden
picturebox at (0,1200).

This works fine and the sprite is displayed at the top the scrolled
down form.

However the "y" coordinate of the picturebox is now 1 instead of 601.
It appears as soon as the form is scrolled the x,y cordinates become
relative rather than absolute. So that even though we are at position
y=601 because we are at the top of the (scrolled down) form it think
we are at position 1.

Of course this is causing havoc with my collision routine as the
sprite keeps bumping into objects from the top part of the form even
though it is on the bottom part of the form!!!

Does anyone have a solution for this?

p.s. I've tried adding 600 to the "y" value when we first scroll the
form, but this just then moves the sprite to the bottom of the
scrolled down form. I also noticed if you don't scroll the form but
continue to move the sprite down the way then the "y" value keeps it's
absolute value.

Regards,

Scott M.
Jul 17 '05 #1
1 2440
The 'trick' is to use two picture boxes. One acts as the 'viewport', and
its maximum size is the size of the form. The other is contained inside the
'viewport' pixbox and is how ever large you want - it can be thousands of
pixels. Then, you 'move' the inner picturebox inside the 'viewport' opening
to reveal the various portions of your larger canvas. Go to
search.microsoft.com and search the vb knowledge base for the term
"scrollable viewport".

--

Randy Birch
MVP Visual Basic
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.
"Scott M" <sc**********@tiscali.co.uk> wrote in message
news:ea**************************@posting.google.c om...
: Hi,
:
: I am writing a small game that is using a form 800 * 600. The form
: can be scrolled vertically up to a height of 1200 (basically the form
: can be scrolled down one screen vertically).
:
: The user controls a picturebox (my sprite) with the cursor keys
:
: When the sprite hits the y value of 600 the screen scrolls down to
: display the bottom part of the screen (by focusing on a hidden
: picturebox at (0,1200).
:
: This works fine and the sprite is displayed at the top the scrolled
: down form.
:
: However the "y" coordinate of the picturebox is now 1 instead of 601.
: It appears as soon as the form is scrolled the x,y cordinates become
: relative rather than absolute. So that even though we are at position
: y=601 because we are at the top of the (scrolled down) form it think
: we are at position 1.
:
: Of course this is causing havoc with my collision routine as the
: sprite keeps bumping into objects from the top part of the form even
: though it is on the bottom part of the form!!!
:
: Does anyone have a solution for this?
:
: p.s. I've tried adding 600 to the "y" value when we first scroll the
: form, but this just then moves the sprite to the bottom of the
: scrolled down form. I also noticed if you don't scroll the form but
: continue to move the sprite down the way then the "y" value keeps it's
: absolute value.
:
: Regards,
:
: Scott M.

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John Davis | last post by:
I want to know what's the differences between Request.Form("Field Name") and Request.QueryString("Field Name") OR they function exactly the same, which is to return the value of the field?? ...
18
by: Mr.Clean | last post by:
I have a table and would like to make it scroll if more rows are in the table than are visible in the height. How would I do that? overflow: scroll; doesn't work in IE or mozilla on this table.
1
by: Kenneth Keeley | last post by:
Hi If I have a page that has some text boxes and some dropdown list and some buttons How do I go about place a reset button on the page. This button should clear all the text boxes and reset the...
9
by: Dan | last post by:
I am trying to use Request.Form("__EVENTTARGET") to get the name of the control that caused a post back. It keeps returning "". I am not really sure why, this happens for all of my controls...
2
by: Jerry Spence1 | last post by:
I haven't got a "Windows Forms" tab in my toolbox. I think I accidentally right clicked and deleted it. How do I get it back? -Jerry
7
by: Kermit Piper | last post by:
Hello, How can you clear session variables when a reset button is pressed? I thought I might be able to do something like: <% If request.form("Reset") = "Reset" then Session("variable") =...
2
by: Roger Withnell | last post by:
I need to reset a form to its original value using onclick rather than the Reset button. So, I have: <input type="button" name="reset" id="reset" value="Reset" onclick="form1.reset();"> where...
38
by: Sanders Kaufman | last post by:
I'm converting my table-based layouts to css-positioned divs - but the ONLY reason I'm doing it is because it's *considered* a best practice. I don't really see where anything goes hinky when...
1
by: apking | last post by:
Hi friends.. iam trying to reset form fileds with javascript function.but it will not working.iam using this one.. <script language="Javascript"> function reset() {...
3
by: eBob.com | last post by:
How does a "sub-form", i.e. one invoked by another form, determine anything about the form which brought it into existence, i.e., I suppose, instantiated it? I wanted to so something like this ......
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.