Combining multiple pictureboxes into one bigger object

  • (2 Pages)
  • +
  • 1
  • 2

22 Replies - 1743 Views - Last Post: 11 February 2013 - 10:33 AM Rate Topic: -----

#1 Jondeate  Icon User is offline

  • D.I.C Head

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

Combining multiple pictureboxes into one bigger object

Posted 10 February 2013 - 03:31 PM

Is it possible to combine two pictureboxes?

For example, this "_" is picturebox1. This "_" is picturebox2. Is it possible to put them like "__" and treat "__" as one object?

Thank you
Is This A Good Question/Topic? 0
  • +

Replies To: Combining multiple pictureboxes into one bigger object

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3234
  • View blog
  • Posts: 10,859
  • Joined: 12-December 12

Re: Combining multiple pictureboxes into one bigger object

Posted 10 February 2013 - 03:53 PM

Not sure what your intention is but you can place the two pictureboxes in a Panel; they would be children of this panel and could be treated as as a pair (a collection).

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.
Was This Post Helpful? 1
  • +
  • -

#3 Jondeate  Icon User is offline

  • D.I.C Head

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

Re: Combining multiple pictureboxes into one bigger object

Posted 10 February 2013 - 03:57 PM

Thanks mate.
How do i create a collection?
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3234
  • View blog
  • Posts: 10,859
  • Joined: 12-December 12

Re: Combining multiple pictureboxes into one bigger object

Posted 10 February 2013 - 03:58 PM

Hint:
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.
Was This Post Helpful? 1
  • +
  • -

#5 Jondeate  Icon User is offline

  • D.I.C Head

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

Re: Combining multiple pictureboxes into one bigger object

Posted 10 February 2013 - 04:00 PM

I created a path in which the player on my game can walk on.
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

Was This Post Helpful? 0
  • +
  • -

#6 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3234
  • View blog
  • Posts: 10,859
  • Joined: 12-December 12

Re: Combining multiple pictureboxes into one bigger object

Posted 10 February 2013 - 04:02 PM

View PostJondeate, on 10 February 2013 - 03:57 PM, said:

Thanks mate.
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

Was This Post Helpful? 2
  • +
  • -

#7 Jondeate  Icon User is offline

  • D.I.C Head

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

Re: Combining multiple pictureboxes into one bigger object

Posted 10 February 2013 - 04:05 PM

Thanks, i will look into that and see if it fits my requirements
Was This Post Helpful? 0
  • +
  • -

#8 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3234
  • View blog
  • Posts: 10,859
  • Joined: 12-December 12

Re: Combining multiple pictureboxes into one bigger object

Posted 10 February 2013 - 04:07 PM

View PostJondeate, on 10 February 2013 - 04:05 PM, said:

Thanks, i will look into that and see if it fits my requirements

No problem. Good luck!
Was This Post Helpful? 2
  • +
  • -

#9 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2241
  • View blog
  • Posts: 9,412
  • Joined: 29-May 08

Re: Combining multiple pictureboxes into one bigger object

Posted 10 February 2013 - 04:16 PM

Why are you using picture boxes?

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


Was This Post Helpful? 1
  • +
  • -

#10 Jondeate  Icon User is offline

  • D.I.C Head

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

Re: Combining multiple pictureboxes into one bigger object

Posted 10 February 2013 - 04:25 PM

This seems like a genius idea i cant yet wrap my head around.
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

Was This Post Helpful? 0
  • +
  • -

#11 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2241
  • View blog
  • Posts: 9,412
  • Joined: 29-May 08

Re: Combining multiple pictureboxes into one bigger object

Posted 10 February 2013 - 04:36 PM

I more to get you out of idea of control and form based thinking.

VB.net is an object orientated language, create your own objects.
Was This Post Helpful? 1
  • +
  • -

#12 Jondeate  Icon User is offline

  • D.I.C Head

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

Re: Combining multiple pictureboxes into one bigger object

Posted 10 February 2013 - 04:43 PM

View PostAdamSpeight2008, on 10 February 2013 - 04:36 PM, said:

I more to get you out of idea of control and form based thinking.

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

Was This Post Helpful? 0
  • +
  • -

#13 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2241
  • View blog
  • Posts: 9,412
  • Joined: 29-May 08

Re: Combining multiple pictureboxes into one bigger object

Posted 10 February 2013 - 05:08 PM

Care to enlighten everyone with your discoveries?

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

Was This Post Helpful? 1
  • +
  • -

#14 Jondeate  Icon User is offline

  • D.I.C Head

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

Re: Combining multiple pictureboxes into one bigger object

Posted 10 February 2013 - 05:20 PM

Assuming a tile is a block on the map on which the player can or cannot walk on, and the player moves 1 tile per step, i would have to worry about one tile, which is the next tile for the player to walk on.

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)
Posted Image

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

Was This Post Helpful? 0
  • +
  • -

#15 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1043
  • View blog
  • Posts: 4,057
  • Joined: 02-July 08

Re: Combining multiple pictureboxes into one bigger object

Posted 10 February 2013 - 05:46 PM

That's what I been talking about the whole other thread. Design the class objects and define properties. You make a Bounds property like a Rectangle(simple) or Region(complex). Then draw these items to the canvas surface - the canvas being a control of your choice - picturebox for the best rendering.
Was This Post Helpful? 1
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2