Object ID's

New to FreeBASIC? Post your questions here.
TurtleProgrammer
Posts: 35
Joined: Jan 26, 2017 7:54

Object ID's

Postby TurtleProgrammer » May 18, 2018 8:11

Is there any way to assign ID's to object. For example, if I have 5 boxes on the screen box 1 would have b1, box 2 would be b2, etc. etc. I am writing a scrolling game that has MORE than 5 boxes (or tiles in my program) and they don't all fit on the screen at the same time. So I thought I would implement scrolling in my game. The best way I can figure is for the program to call objects by their ID's.
grindstone
Posts: 452
Joined: May 05, 2015 5:35
Location: Germany

Re: Object ID's

Postby grindstone » May 18, 2018 8:47

I would suggest to create an array of boxes and use the array index as ID.

Code: Select all

Type tBox
   ...
End Type

Dim box(0 To 5) As tBox
MrSwiss
Posts: 2479
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Object ID's

Postby MrSwiss » May 18, 2018 11:27

For a alternative way (visibility ON/OFF) see the Type (struct) in this post's code section.
You can in this way, speed up the refresh procedure, by NOT drawing, what is
outside of the current view-port (part screen currently shown to user).

Code: Select all

' assume, procedure implementation starts here:
    If Not [Rectangle].vis Then Exit Sub/Function  ' whatever it may be: inside [...] and proc. type
    ' from here, start drawing implementation ...
paul doe
Posts: 534
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Object ID's

Postby paul doe » May 18, 2018 11:53

TurtleProgrammer wrote:Is there any way to assign ID's to object...

Of course there is a way. Can you show some code, to have a better idea of what you're trying to accomplish? Also, which type of game we're talking about? Side-scroller, Top-down, other?

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 1 guest