Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
manage objects automatically
#17
I had a short look now, and I'm a bit confused Smile

Let's focus on the main file, example-father, for now:

Code:
while not keydown(KEY_ESCAPE,true)
    set color 0,0,0
    cls
    '--------------------------------------------------
    Father().Update_all()
    Father().Draw_all()
    'eliminar todo
    if keydown(KEY_X,false)
        Father().Clear()
    endif
    '--------------------------------------------------
    redraw
    fwait 60
wend

Here you create a new father object every time you call Father(), which is a bit "strange" and not optimal.

The problem is that you have made the "base class", Father, serve as a sprite manager. If I were you, I would remove the functions Add, Update_all, Draw_all, Destroy and Clear from Father and put them in regular functions, or create another "class" (a sprite manager) whose only job is to manage a list of sprites.

I've attached a new example-father.n7 and father1.n7 where I've made the change that I suggested. Every function that deals with the sprite list (fatherList) are now regular functions. I didn't remove the functions from the father "class", but they now call the independant functions.


Attached Files
.n7   example-father.n7 (Size: 706 bytes / Downloads: 2)
.n7   father1.n7 (Size: 2.47 KB / Downloads: 2)
Reply


Messages In This Thread
manage objects automatically - by aliensoldier - 11-11-2023, 07:01 PM
RE: manage objects automatically - by Marcus - 11-11-2023, 09:46 PM
RE: manage objects automatically - by Marcus - 11-12-2023, 09:10 AM
RE: manage objects automatically - by Marcus - 11-13-2023, 02:57 PM
RE: manage objects automatically - by Marcus - 11-14-2023, 04:30 PM
RE: manage objects automatically - by Marcus - 11-16-2023, 04:13 PM
RE: manage objects automatically - by Marcus - 11-14-2023, 07:47 PM
RE: manage objects automatically - by Marcus - 12-09-2023, 09:28 PM
RE: manage objects automatically - by Marcus - 12-18-2023, 04:08 PM
RE: manage objects automatically - by Marcus - 12-18-2023, 05:11 PM
RE: manage objects automatically - by Marcus - 01-18-2024, 04:49 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)