Object ID's

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

Object ID's

Post by TurtleProgrammer »

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: 862
Joined: May 05, 2015 5:35
Location: Germany

Re: Object ID's

Post by grindstone »

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: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Object ID's

Post by MrSwiss »

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
Moderator
Posts: 1730
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Object ID's

Post by paul doe »

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?
Post Reply