LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to endlessly create and delete picture programmatically.

Solved!
Go to solution

HI.

 

I'm a student.
I'm making a Plants VS Zombies type of game in LabVIEW as one of my final projects. One feature of it is the plants shoot out endless bullets to defeat endless enemies approaching.

 

I'm having trouble on what kind of technique I should use to endlessly programmatically create and delete front panel 2dPicture -that is because, the plants, bullets, and enemies are 2DPicture type.

 

I don't have that much time to learn about Objects and Draw palette so I kind of cheated the program as all 2DPictures. If it's any info, I have less than a month.

Message 1 of 8
(3,054 Views)

Hello,

you can't dynamically create front panel objects in LabVIEW, you would have to create them manually in advance and manage them programmatically.

A better solution is to draw your objects in a 2D Picture Control. For a first start I attach an example how to animate drawing objects this way.

Greets, Dave
Message 2 of 8
(2,995 Views)

Thank you Dave! Much appreciated 🙂

you can't dynamically create front panel objects in LabVIEW,

Knowing that it is not possible to do so is already a big help for me. I might've spent two or more days looking for it!


 For a first start I attach an example how to animate drawing objects this way.


the VI you sent (quite intimidating, those wires are) is an example of drawing object. I haven't grasped around that topic yet but I think that programmatically drawing the object is indeed more proper, but inserting 2DPictures would work the same, so I think I'd still go with the 2DPicture?


A better solution is to draw your objects in a 2D Picture Control


Unless there are other pros for programmatically drawing the 2D (is there?)

And 



you would have to create them manually in advance and manage them programmatically.


This here is the solution. I am thinking about manually creating at least 10 bullets then reuse it in a loop; see if the bullet is in motion then access that to animate again and deal damage/any interactions.

Now my next question is any technique on how to this so?

0 Kudos
Message 3 of 8
(2,983 Views)

In this thread in the Breakpoint I have collected links to many threads that have examples that use the Picture control.

 

A very basic approach to your challenge would start with an array of images in a block diagram constant that you can index and insert where it needs to be in the picture.

 

Start out simple (get base functionality in place before you embellish!) with tracking where things should be in the image.

 

Have fun!

 

Ben 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 4 of 8
(2,969 Views)

Sorry, I forgot to mention that a lot of the "intimidating" wire part is the handling of keystrokes to change the bullet direction and the very good scalable state machine design with events. This makes this example prepared for enhancements.

Greets, Dave
0 Kudos
Message 5 of 8
(2,954 Views)

A very basic approach to your challenge would start with an array of images in a block diagram constant that you can index and insert where it needs to be in the picture.

This is what I was thinking. I cant quite map my mind on how and where to start and continue the process. in short, the method is kind of tricky and I admit I'm less experienced in this. Just a short background, this software is a subject in my engineering course and its just been one and a half month.

Could you please elaborate the method? or maybe is there a terminology for this technique?

thank u in advance 🙂

0 Kudos
Message 6 of 8
(2,896 Views)
Solution
Accepted by topic author Toptunov

https://en.wikipedia.org/wiki/Pool_(computer_science)

 

The term you're looking for is "Object Pooling".  It's very common in games with a large number of identical game objects that need to be instantiated but then get destroyed (like bullets).  

 

A little hint:   You'll get a lot more people viewing (and helping you with) your VI if you back-save it a version or two.  Many of us haven't upgraded to 2019 yet...

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
Message 7 of 8
(2,874 Views)

The term you're looking for is "Object Pooling". 


WOW is that it. Thank you, i need that technique. but im not positive enough to believe i will learn that in a day or two.


You'll get a lot more people viewing (and helping you with) your VI if you back-save it a version or two.  Many of us haven't upgraded to 2019 yet...

My bad, here it is. I back-saved it. It's not good all good-practice I did there. I dont know much about planning the design before actually applying it to LabVIEW we were just lectured right away without planning so-.

Please open project first. The part where I'm having trouble is the "bullet reuse try.vi" its where i try to get a grasp on the process and will finally incorporate it to "Main.vi" soon as I familiarize myself with the technique. 

Please if you have time, could you help me if there is something I should do, or tips on doing "Object pooling" if it is applicable on that vi, etc. (like a professional consultation 🙂 )

I only have had a month and a half of experience in this software.

Thank you so much! 🙂

0 Kudos
Message 8 of 8
(2,858 Views)