473,320 Members | 2,020 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,320 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 thinks
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.
Nov 20 '05 #1
1 844
Yes, its a pain but you need to apply the AutoScrollPosition property to
your coordinates.

"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 thinks
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.

Nov 20 '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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.