22 Replies - 687 Views - Last Post: 11 February 2013 - 10:33 AM
#1
Combining multiple pictureboxes into one bigger object
Posted 10 February 2013 - 03:31 PM
For example, this "_" is picturebox1. This "_" is picturebox2. Is it possible to put them like "__" and treat "__" as one object?
Thank you
Replies To: Combining multiple pictureboxes into one bigger object
#2
Re: Combining multiple pictureboxes into one bigger object
Posted 10 February 2013 - 03:53 PM
This may not be necessary, as you can simply create a collection (a List or whatever..) in VB and add the two PictureBoxes to this collection.
#3
Re: Combining multiple pictureboxes into one bigger object
Posted 10 February 2013 - 03:57 PM
How do i create a collection?
#4
Re: Combining multiple pictureboxes into one bigger object
Posted 10 February 2013 - 03:58 PM
Insert the Panel first; make sure it is selected and then double-click a PictureBox in the Toolbox (you'll need to pin the Toolbox) - this will make the Panel the parent of the PictureBox, rather than having to do this programmatically.
#5
Re: Combining multiple pictureboxes into one bigger object
Posted 10 February 2013 - 04:00 PM
As all maps do not have totally rectangular paths, i need to find a way to combine "paths" and keep the player going.
But i am not sure using a panel would solve this
This post has been edited by Jondeate: 10 February 2013 - 04:02 PM
#6
Re: Combining multiple pictureboxes into one bigger object
Posted 10 February 2013 - 04:02 PM
Jondeate, on 10 February 2013 - 03:57 PM, said:
How do i create a collection?
This is covered within the first few chapters of any introductory text for VB.NET. If you don't know how to do this then I suggest you need to take a few steps back and cover - I mean study - the fundamentals first.
MSDN - this looks a good reference to the subject.
This post has been edited by andrewsw: 10 February 2013 - 04:04 PM
#7
Re: Combining multiple pictureboxes into one bigger object
Posted 10 February 2013 - 04:05 PM
#8
Re: Combining multiple pictureboxes into one bigger object
Posted 10 February 2013 - 04:07 PM
#9
Re: Combining multiple pictureboxes into one bigger object
Posted 10 February 2013 - 04:16 PM
Sit back from the computer grab a pencil and paper and design.
The basic core structure use in you game.
Eg something like so.
Public MustInherit Class Tile
Protected Friend _PlayerCanWalkOn As Boolean
Protected Friend _ID As Guid
Public ReadOnly Property ID() As Guid
Get
Return _ID
End Get
End Property
Protected Friend _N As Tile
Public Property N() As Tile
Set(Value As Tile)
If Value.ID <> Me.ID Then _N=Value
End Set
Get
Return _N
End Get
End Property
Protected Friend _E As Tile
Public Property E() As Tile
Set(Value As Tile)
If Value.ID <> Me.ID Then _E=Value
End Set
Get
Return _E
End Get
End Property
Protected Friend _S As Tile
Public Property S() As Tile
Set(Value As Tile)
If Value.ID <> Me.ID Then _S=Value
End Set
Get
Return _S
End Get
End Property
Protected Friend _W As Tile
Public Property W() As Tile
Set(Value As Tile)
If Value.ID <> Me.ID Then _W=Value
End Set
Get
Return _W
End Get
End Property
Public ReadOnly Property PlayerCanWalkOn() As Boolean
Get
Return _PlayerCanWalkOn
End Get
End Get
MustOverride Sub DrawTile(g As Graphic)
End Sub
Protected Friend Sub New(CanWalkOn As Boolean)
_PlayerCanWalkOn = WalkOn
_ID = New Guid()
End Class
End Class
Public Class Grass
Inherits Tile
Public Sub New()
MyBase.New(CanWalkOn:=True)
End Sub
End Class
Public Class Wall
Inherits Tile
Public Sub New()
MyBase.New(CanWalkOn:=False)
End Sub
End Class
#10
Re: Combining multiple pictureboxes into one bigger object
Posted 10 February 2013 - 04:25 PM
COudl you give me and idea of how to actually run this code? or use it?
I see this for example:
Public Class Grass
Inherits Tile
Public Sub New()
MyBase.New(CanWalkOn:=True)
End Sub
End Class
If i declare
Private A as new Grass
How do i use it?
Thank you a lot!
This post has been edited by Jondeate: 10 February 2013 - 04:37 PM
#11
Re: Combining multiple pictureboxes into one bigger object
Posted 10 February 2013 - 04:36 PM
VB.net is an object orientated language, create your own objects.
#12
Re: Combining multiple pictureboxes into one bigger object
Posted 10 February 2013 - 04:43 PM
AdamSpeight2008, on 10 February 2013 - 04:36 PM, said:
VB.net is an object orientated language, create your own objects.
I loved your idea of using. i just dont seem to understand it fully (not even 30 percent of it to be serious..), so im trying to adjust to what my corrent knowdledge can afford.
I will try to study this example anyways.
Thanks
Edit* Just figured out how to fix my problem. Thought, i feel stupid for having to use pictureboxes existing a better way to do this.
This post has been edited by Jondeate: 10 February 2013 - 04:51 PM
#13
Re: Combining multiple pictureboxes into one bigger object
Posted 10 February 2013 - 05:08 PM
While you're thinking about the design.
Based my design, how many tiles would have to worry about to see if the character can move to, based on the current tile position?
This post has been edited by AdamSpeight2008: 10 February 2013 - 05:13 PM
#14
Re: Combining multiple pictureboxes into one bigger object
Posted 10 February 2013 - 05:20 PM
Not that what i just said makes much sense.. does it
And about how did i fixt it.
Since i use pictureboxes to draw the shape i want the rectangle asigned to them have, i just said that if the player wasnt on the first picturebox and it wasnt on the second, which was overlapping the first one, it will execute the "wall repel" action.
SOmething like
If Not rwall1.Contains(rplayer) Then
If Not rwall2.Contains(rplayer) Then
loc = New Point(ObjPersonaje.Location.X, ObjPersonaje.Location.Y - 6)
ObjPersonaje.Location = loc
THough it didnt work if i put both evaluation on the same if.
This is how i was testing it (yes, it looks like that on purpose)

Bscly, if pbx1 doest not contain the player rectangle, and pbx2 does, it can move in that direction too.
This post has been edited by Jondeate: 10 February 2013 - 05:32 PM
#15
Re: Combining multiple pictureboxes into one bigger object
Posted 10 February 2013 - 05:46 PM
|
|

New Topic/Question
Reply



MultiQuote





|