473,586 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2450
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.microsof t.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**********@t iscali.co.uk> wrote in message
news:ea******** *************** ***@posting.goo gle.com...
: 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
17742
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?? Thanks, John
18
9257
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
355
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 dropdown list to the default value. Thanks
9
21475
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 that invoke are invoking a post back. I've never used this type of method before, but I need to get the name of the control doing the postback in...
2
948
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
14614
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") = Null %>
2
5219
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 the id of my form is "form1". This gives the error "Object doesn't support this property or method". Please advise.
38
3273
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 tables are used - but I'm doing it anyway because the HTML and CSS specs says to reserve tables for tabular data. So as I convert my login widgit to...
1
1691
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() { document.regform.fname.value = ""; document.regform.email.value = ""; document.regform.passwd.value = ""; document.regform.passwd1.value = ""; document.regform.city.value =...
3
1899
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 ... MsgBox("called by " & Owner.Name) .... but that throws a null reference exception. Parent.Name and ParentForm.Name also throw null reference...
0
7912
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8202
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8216
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.