Most Practical way of setting multiple limits in multiple forms.

• (2 Pages)
• 1
• 2

18 Replies - 1424 Views - Last Post: 10 February 2013 - 03:35 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=311725&amp;s=0be35bd608b468d83f389e6740696fad&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

#1 Jondeate

Reputation: 0
• Posts: 56
• Joined: 03-February 13

Most Practical way of setting multiple limits in multiple forms.

Posted 09 February 2013 - 03:10 PM

Hello,

Ive been making the basic structure of my RPG game in Visual Basic 2010, Ive got almost everything i need to start the game itself whit not much effort.

But right now, i want to know what is the most practial way to set map limits in the forms.

I did this in early games by setting the "map" as the form background, then placing transparent pictureboxes boxes over the things i didnt want the player to go walking on (Ex. trees, houses.),then, i would create Rectangles whit equal dimentions as the pictureboxes (I used transparent pictureboxes so i could set the limits visually instead of editing the rectangles blindly)then, i would put that if the rectangle that was equal to the player intersected whit the rectangle that was the wall, for example, it wouldnt walk.

But now i think this method could be simplified, i just need a heads up in the right direction

Thank you all

Is This A Good Question/Topic? 0

Replies To: Most Practical way of setting multiple limits in multiple forms.

#2 _HAWK_

• Master(Of Foo)

Reputation: 1160
• Posts: 4,443
• Joined: 02-July 08

Re: Most Practical way of setting multiple limits in multiple forms.

Posted 09 February 2013 - 05:01 PM

If I was using Winforms for this, I would not use pictureboxes, but rather draw rectangles using GDI+ as they render faster than controls and guarantee transparency. This design is also not control heavy if there are a lot of runtime generated controls. I don't mind the base of the form to have 1 pictureBox as the canvas. I would most likely use custom classes for objects draw to the surface as they would hold properties and would be easy to access and modify. My 2 cents!

#3 LilGhost

Reputation: 8
• Posts: 98
• Joined: 12-October 12

Re: Most Practical way of setting multiple limits in multiple forms.

Posted 09 February 2013 - 05:25 PM

... I don't know why you'd want to do this in vb.net... Possible, yes. Practical, not really. However, i do believe directX can be implemented with vb.net? (Not 100% but about 80% sure) DirectX would probably be a better way to do this and still do it in vb.net.

#4 Jondeate

Reputation: 0
• Posts: 56
• Joined: 03-February 13

Re: Most Practical way of setting multiple limits in multiple forms.

Posted 09 February 2013 - 07:35 PM

_HAWK_, on 09 February 2013 - 05:01 PM, said:

If I was using Winforms for this, I would not use pictureboxes, but rather draw rectangles using GDI+ as they render faster than controls and guarantee transparency. This design is also not control heavy if there are a lot of runtime generated controls. I don't mind the base of the form to have 1 pictureBox as the canvas. I would most likely use custom classes for objects draw to the surface as they would hold properties and would be easy to access and modify. My 2 cents!

Thank you very much, may i say!
What would you say its the best soruce to guide myself trough 'GDI+', as im new to that.

LilGhost, on 09 February 2013 - 05:25 PM, said:

... I don't know why you'd want to do this in vb.net... Possible, yes. Practical, not really. However, i do believe directX can be implemented with vb.net? (Not 100% but about 80% sure) DirectX would probably be a better way to do this and still do it in vb.net.

Sir, its my semester project.
Thank you, ill look into that

Oh, i forgot to ad 'HAWK', that i think using rectangles to draw objects its not possible for my project. As all elements on the map are ripped of from a RPG engine, and its easier to just print screen the map i created there and put it as background.
Thanks

#5 _HAWK_

• Master(Of Foo)

Reputation: 1160
• Posts: 4,443
• Joined: 02-July 08

Re: Most Practical way of setting multiple limits in multiple forms.

Posted 09 February 2013 - 07:41 PM

Does not matter how you make the background - though I have no idea what ripped from an rpg engine means. GDI+ is just a way to draw on top of it. BobPowell.Com!

#6 Jondeate

Reputation: 0
• Posts: 56
• Joined: 03-February 13

Re: Most Practical way of setting multiple limits in multiple forms.

Posted 09 February 2013 - 08:09 PM

Ooohh. now that makes sense. Thank you

#7 Jondeate

Reputation: 0
• Posts: 56
• Joined: 03-February 13

Re: Most Practical way of setting multiple limits in multiple forms.

Posted 09 February 2013 - 08:50 PM

So ive been thinking and, i saw three ideas on different threads regarding this kind of issue

One of them said that instead of checking the 'player' object to collide whit 'walls' objetcs,
i should check for walls to collide whit the player object. Is this a better way?

One comment said that it is better to use bouce spheres, what is this?

the other one said that i should create a collision engine to check if anybody is colliding whit anybody, but i have no idea on how to approach this.

#8 _HAWK_

• Master(Of Foo)

Reputation: 1160
• Posts: 4,443
• Joined: 02-July 08

Re: Most Practical way of setting multiple limits in multiple forms.

Posted 09 February 2013 - 09:40 PM

After you create the objects, if they have the rectangle properties its a matter of looping thru the collection and determine if any Rectangle.IntersectsWith another and determine which type is has collided with. This would be simple if you use a class object cause you can have another property to check it's type and have a response as needed. Once you build the rules inside each class type you can have this functionality done by a simple method or by setting properties that direct changes by their values.

#9 Jondeate

Reputation: 0
• Posts: 56
• Joined: 03-February 13

Re: Most Practical way of setting multiple limits in multiple forms.

Posted 09 February 2013 - 10:08 PM

You. Are. Awesome.
Thank you.
I will try to implement the loop thingy..

What do you mean for 'type' of rectangle?

I was now experimenting whit my code.
i created a rectangle and a timer which looks for instersections. If the player intersects whit the wall WHILE going to one direcction, the player will go the opposite direccion the same ammount of steps.

I was trying to make the player just stop moving, which is what i really wanted, and i did, and it works well if the player can only touch the rectangle from one side. This by saying that if the player intersected whit the rectangle while going right, boolean Intersect would be true, and player would not be able to move right.
This does not work on more than two directions because if the boolean intersects = true for both left and right side, player wont be able to move left if it touched the object while moving right.
is there a way to make it work?

Thanks

#10 Jondeate

Reputation: 0
• Posts: 56
• Joined: 03-February 13

Re: Most Practical way of setting multiple limits in multiple forms.

Posted 09 February 2013 - 10:18 PM

Edit.
I think the solution might be to evaluate if they WILL intersect on the next player step.
Like simulating the next player step or something..
am i right?

#11 _HAWK_

• Master(Of Foo)

Reputation: 1160
• Posts: 4,443
• Joined: 02-July 08

Re: Most Practical way of setting multiple limits in multiple forms.

Posted 09 February 2013 - 10:32 PM

For intersectin,g yes. I would create a rectangle that would represent the new location and test.

#12 Jondeate

Reputation: 0
• Posts: 56
• Joined: 03-February 13

Re: Most Practical way of setting multiple limits in multiple forms.

Posted 09 February 2013 - 11:10 PM

Even when i do the text whit another rectangle, i cant get it to work whit more than two directions

*Edit i meant test

#13 Jondeate

Reputation: 0
• Posts: 56
• Joined: 03-February 13

Re: Most Practical way of setting multiple limits in multiple forms.

Posted 10 February 2013 - 07:52 AM

The code goes like:

Player = Object 1
Playertest = Object 2
playertest.location = player.location
Variable Intersects as Boolean
PLayer = new rectangle
Wall = new rectangle
Timer if playertest intersects whit wall, Intersects = True

(In the code of the player walking animation and moving to the right/left whatever.)
Loc = new point (playertest.location.x + 5, playertest.location.y)
playertest.location = loc

if intersecs = false then
loc = new point (player.location.x+, player.location.x)
player.location = loc
playertest.location = player.location
else
(nothing happenns
end if

TO my understanding, this would first test if the playertest intersects whit the wall, before actually moving the player itself. Then, if intersects = false, it moves the player to that position and resets the playertest position to the player position, so it can start the cycle again.

Is my logic wrong in some aspect? thank you

#14 _HAWK_

• Master(Of Foo)

Reputation: 1160
• Posts: 4,443
• Joined: 02-July 08

Re: Most Practical way of setting multiple limits in multiple forms.

Posted 10 February 2013 - 02:03 PM

All the walls should be in a collection. The players movement is always compared to the walls prior to moving.

#15 andrewsw

• But the opposite, you said.

Reputation: 5518
• Posts: 21,772
• Joined: 12-December 12

Re: Most Practical way of setting multiple limits in multiple forms.

Posted 10 February 2013 - 02:12 PM

_HAWK_, on 10 February 2013 - 02:03 PM, said:

All the walls should be in a collection. The players movement is always compared to the walls prior to moving.

..I suppose if it were a large map you might divide it into sectors, so that you are not checking every wall, each time? But then you would have to handle the situation where a wall crosses (one or more) sectors.

(Just speculating)

This post has been edited by andrewsw: 10 February 2013 - 02:13 PM