Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / AgkSharp for Windows - General Questions And Feedback

Author
Message
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 7th Oct 2018 12:13
The 32 bit version works as it was intended!

The 64 bit gave me an exception as shown below.
www.alexmatei.com

Attachments

Login to view attachments
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 7th Oct 2018 12:32
You have to manually set your project to 64bit. Then it should work. In VS in the upper bar, simply set it from Debug to Release 64.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 7th Oct 2018 12:47
Hats down to you, MadBit!

Thank you so much for the help provided!
www.alexmatei.com
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 9th Oct 2018 08:57
Hello!

One quick question regarding the code itself:

I try to detect some images from the hard drive and then to detect in a for loop if the images does not exist, to able to fill those slots. However from the following code, it gives me a message that the application is in break mode (the app stalls).



Thank you!
www.alexmatei.com
stan10785
5
Years of Service
User Offline
Joined: 15th Aug 2018
Location:
Posted: 9th Oct 2018 10:24
Thanks for all the work on this MadBit - I see that the hiccup around the mouse was resolved in the update and works like a gem! Still waiting for you to set up that Patreon page so we can help you out more!
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 9th Oct 2018 13:12
I have slightly modified your code. This is how it should work. (Not tested)
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 9th Oct 2018 13:26 Edited at: 9th Oct 2018 13:40
Madbit,

Thank you!

It didn't gave me any errors. The absolutely last thing: In order for the images to appear on screen, is this the correct method to create the sprites?



Thank you, again!
www.alexmatei.com
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 9th Oct 2018 14:24
If you only want to use the images once for one sprite, you can also just use LoadSprite.
So something like this.



The way you do it is also O.K.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 9th Oct 2018 14:35
There are multiple sprites with different images. So if I have different images and different sprites, I can still use the LoadSprite command? Didn't knew about this method... is a lot more cleaner. Silly me.
However with my method and the alternative method from you, don't know why the sprites don't appear on screen.

The whole code again:



Sorry for asking so many questions, but I made the decision to transfer my project in C# AppGameKit and got stuck just on these problems.

Thank you!
www.alexmatei.com
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 9th Oct 2018 15:17
Debug your code to see if the sprites are really loaded.
If you don't know how to do this you can also use the code below.
If more than one sprite is loaded, a number above 1000 should be displayed.

If the sprites were not loaded, it is probably because the path was not set correctly. Then try it with
Agk.SetFolder("media/tools/assets");

I changed your code again.

Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 9th Oct 2018 16:21
You where right!

It was because the "media" folder was not included. I got used to AppGameKit Basic IDE to actually get the "media" folder automatically.

Huge thank you for your help! It helped me a lot!
www.alexmatei.com
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 10th Oct 2018 11:44
Hello,

Sorry for asking again about certain things on C#, maybe someone also could run into the same problem. It's about arrays, in general. I want to make them public to be accessed from another form or function.

I have the following, as an example:



I tried public static but it throws me errors like the one attached on this post.

Thank you so much!
www.alexmatei.com

Attachments

Login to view attachments
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 10th Oct 2018 19:51
I think it's the way of declaring the variables. Try it with 'static' in front.

Something like that:


If not, a little more information would be better.

What does the class look like in which the variables are declared?
What compiler errors are output?
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 11th Oct 2018 08:32
Hello Madbit,

I will try your alternative. In the meantime, I managed to create classes for every array and make them public so that they can be accessed from anywhere in the application. However, I would really like for your example to work. It looks much more neat.

Here is what I have managed to do:



And access the array by: textarray.texthassprite[number] = variable to put.

I think this is another way to do it?
www.alexmatei.com
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 11th Oct 2018 14:48 Edited at: 11th Oct 2018 15:13
Hmm, I would approach it from the other side.
I would put all the properties into a structure and then save the entries in a list.
Something like that.


To add values ...


enumerate all items in the list


But all this is only estimated, because I don't know what you want to do with the data and how you use it.
And it is also a personal decision, how you can work best.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 11th Oct 2018 15:11
I understand. I'll try.

I identified that the keyboard does not work when I initialize either "getrawkeypressed" or "getrawkeystate". Also on settweentextred, green or blue and maybe to the rest of the tweens, the values are only INTEGER, not FLOAT as in the basic version.

Thank you!
www.alexmatei.com
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 11th Oct 2018 16:23 Edited at: 11th Oct 2018 16:24
MateiSoft wrote: "Also on settweentextred, green or blue and maybe to the rest of the tweens, the values are only INTEGER, not FLOAT as in the basic version."

This is the Tier2 declaration of this Function.

You see it is an 'int'. It won't do any difference if I change it to float. I didn't find anything in the documentation that it should be a float.

MateiSoft wrote: "I identified that the keyboard does not work when I initialize either "getrawkeypressed" or "getrawkeystate". "

Ok, thank you for this.

It only works if the AppGameKit window gets the focus. So you can insert the following line as workaround in the file 'Core.cs' and function Core_OnMouseDown.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 15th Oct 2018 17:44
Ok,

I have quickly uploaded a new package. It is only compiled with the current version of AppGameKit (2018-10-10).

As always, download it from my site.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
snaidamast
5
Years of Service
User Offline
Joined: 16th Oct 2018
Location:
Posted: 18th Oct 2018 17:42
I am looking at converting my military simulation from MonoGame to AGKSharp due to the much greater capability of providing a user interface with the Windows Forms controls.

However, how does one create a panel that can be scrolled as with a large hexagonal map. With MonoGame we used the primary camera and changed its position for these purposes.

I also have to build the map using tiles, which already have the routines written in MonoGame. How would I do this with AGKSharp?

Thank you...
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 19th Oct 2018 11:02 Edited at: 19th Oct 2018 11:05
Hello and welcome to the forum.

I don't know if you work in 2D or 3D.

In the case of 2D, you have two choices.
- You create your complete map from tiles. In Agk you use sprites to do this. Afterwards you can move the view with 'SetViewOffset(x, y)' as you like. I suppose this is similar to your MonoGame Project.

or ...

- You calculate which tiles are visible at the current position of the 'camera' and draw only the tiles that are necessary. So you don't need to move the visible area anymore. For very large maps, it could be faster.

There is only one way in 3D.
- You assemble your map using your 3D tiles and set the camera to scroll. So just like you already described it.

For help you can use the official documentation. You just have to put "Agk." in front of the commands.

I hope this helps.
If I have misunderstood you or if there are more questions open then ask further.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Carharttguy
7
Years of Service
User Offline
Joined: 8th Jul 2016
Location: Belgium
Posted: 19th Oct 2018 20:30 Edited at: 19th Oct 2018 21:07
Hello Madbit, super nice to see that you're updating AgkSharp to newer versions of AppGameKit!

I have a question about the inner workings of AgkSharp: is it possible to register AgkSharp.dll as a COM object in Windows? This would expose AgkSharp to almost any Windows programming language!
Next to C#, I'm also using a programming language called Xojo, and that can reference with dlls, but I don't know if this would work with AgkSharp (some basic info here: https://blog.xojo.com/2014/01/03/accessing-net-code-from-xojo/)

I guess DLLRegisterServer has to be added somewhere or so?

Do you think this would be possible? Would be nice for Xojo, as there are no real 3D engines available.

Thanks for any info!
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 20th Oct 2018 05:07
Hi, you have to try this. I didn't declare the AgkSharp functions as COM objects.
But if it should work. You also had to translate the C# code 'Core.cs' into Xojo. Because the window for Agk is created there and the window handle must be passed to Agk.InitGL.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Carharttguy
7
Years of Service
User Offline
Joined: 8th Jul 2016
Location: Belgium
Posted: 24th Oct 2018 07:56
Wasn't as easy as I hoped, I don't have the time at this moment to search for it. Will leave that to a later moment.

Full focus on AgkSharp now, I have a small question, I want to load a 3d object that is at a user specified path (e.g. My Documents), how do I load that object in AgkSharp? I can copy the original file to the media folder, and progress from there, but not sure that is the way to go.
Any advice on this matter?

Thansk for your work!
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 24th Oct 2018 12:27
The normal way would be to copy the file into the media directory. You can also specify the file directly as in AGK.

Or also in combination with the environment variables. (Not tested.)


i hope this helps a bit.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Carharttguy
7
Years of Service
User Offline
Joined: 8th Jul 2016
Location: Belgium
Posted: 25th Oct 2018 14:28 Edited at: 25th Oct 2018 14:38
Nice!
Thanks.

I run into an error when opening a obj file.
When I use AppGameKit Basic I can load it doing this:


When I translate that to AgkSharp (and set Error mode to 2, If I don't set errormode, nothing happens)


I just dropped the man.obj in the /bin/media folder of my C# project.
It throws an error:
Visual Studio wrote: "System.Runtime.InteropServices.SEHException: "An external component has caused an exception.""


Any idea? This happens with the WinForms template.
See man.obj attached, nothing special I think.

Also something else: The donation button on the AppGameKit webpage doens't seem to do anything.

Attachments

Login to view attachments
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 25th Oct 2018 16:35
Hello MadBit,

Sorry for not responding for so long, I've been super busy with the development of my application.

I will respond to the previous messages in a short time. Meanwhile I came back with a question regarding the following problem: My application enters in break mode when I try to initialize this command: "Agk.Message(Agk.GetImageFilename(1000));". It's not "Agk.Message", it's "Agk.GetImageFileName". Do you know why my application enters in break mode?

Thank you very much!
www.alexmatei.com

Attachments

Login to view attachments
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 25th Oct 2018 18:09 Edited at: 25th Oct 2018 21:07
@Carharttguy
This is because Tier2 (C/C++) and CSharp do not set the media directory. This means that the root directory from which the program is read is not the media directory but where the program was started.
To fix it simply use "media/man.obj".

@MateiSoft
That's a similar error to Carharttguy. Check if the Image-Id exists. Check if the image is really loaded/created.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Carharttguy
7
Years of Service
User Offline
Joined: 8th Jul 2016
Location: Belgium
Posted: 25th Oct 2018 19:50
Thanks MadBit for your help, really simple solution indeed..
Is there a way for you to pass throw 'the real' exception as AppGameKit Basic would give?
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 25th Oct 2018 21:12
Unfortunately no.
The exception is output by the c++ library. I call the functions one to one.
I will take a closer look at the c++ source code to see if I can find a simple solution.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 25th Oct 2018 21:41
The donate button now works again.
Thanks for the information.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 25th Oct 2018 22:37 Edited at: 25th Oct 2018 22:40
Are GetImageID and GetImageFilename commands available if I use Clone Sprite?

EDIT: I use



So the sprite appears on the screen when I stay on mouse left click.
When I release the left click I do:

www.alexmatei.com
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 26th Oct 2018 06:41 Edited at: 26th Oct 2018 06:43
If your base sprite (drgnddrpassts) was created with LoadSprite, then your sprite will not have an image ID.
You will also get performance problems, because the image will be reloaded at every cloning, because there is no image reference.

I recommend to create this base sprite with CreateSprite with a previously loaded image.



@Carharttguy & MateiSoft
I have packed new DLL's in the attachment. Now the errors will be more readable. But I left the exception message so that you can see in debug mode which source code line causes the message.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)

Attachments

Login to view attachments
Carharttguy
7
Years of Service
User Offline
Joined: 8th Jul 2016
Location: Belgium
Posted: 26th Oct 2018 07:47
Wow, very nice MadBit! Those exceptions are way more readable indeed! Especially for beginners.
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 26th Oct 2018 08:47
That's weird because in Basic the code works and retrieves an image number.
www.alexmatei.com
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 26th Oct 2018 09:27
Sorry, but a fast test in Agk-Basic gives me a image id of 0 (zero).

Code:
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 26th Oct 2018 10:12
Not at load sprite, but "clone sprite".

www.alexmatei.com
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 26th Oct 2018 10:44
Ok, well. I've tested a couple of times and the only problem that I had it was because of "Load Sprite" not returning an image number. It gave me a nightmare alongside with C# and it's warnings or errors.

Thank you!
www.alexmatei.com
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 26th Oct 2018 13:04
Although it doesn't. Logically it should. I will ask further to see if it's a bug or not.
www.alexmatei.com
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 26th Oct 2018 19:17 Edited at: 26th Oct 2018 19:20
MateiSoft wrote: "Not at load sprite, but "clone sprite".
"

The way you've probably already figured it out.
If the original sprite was created with LoadSprite, this sprite has no image ID. When cloning, the image is reloaded into the cloned sprite because there is no image ID.

I don't think it's a bug. In the documentation of LoadSprite it is already pointed out that the image is reloaded again and again. An image class is created but not passed to the image manager. The Sprite has the exclusive right to access the image.
If the sprite is deleted, the image is also deleted.
I think they wanted to leave the ID resources for the user and not "waste" them for the automatism. It's just a guess.

i personally don't think it's a big deal to make the sprite the way it's been suggested.


or you do a little helper function.


@c0d3r9
Thank you for test this out.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 27th Oct 2018 12:59
I understand. Thanks to you and the other people around here I got to finally understand how some things work.

One C# question: I want to generate picture boxes depending on how many files are in a certain folder. I managed to do that, I also managed to place the in picture box's name, the filename detected, however, when it comes to clicking on picture boxes that contains different filenames, it throws me the same filename as the other picture boxes. Code:



Bless you!
www.alexmatei.com
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 27th Oct 2018 18:22
Thank you.

The way you try, you always get the last PictureBox you created, right?
To work with the controls you just clicked on, you first have to cast the sender object into your corresponding control. In this case into a PictureBox.
Any control that creates an event is passed as sender to the callback function.

for it to work, your function should look something like this.



I hope it works.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 27th Oct 2018 22:22
It surely worked!

Thank you a million!
www.alexmatei.com
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 28th Oct 2018 13:55
MadBit,

Doesn't playsound support an ID number greater than 999? My application enters in break mode when I try to do:



Thank you!
www.alexmatei.com
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 28th Oct 2018 15:36
I checked the source code. The user defined id must be between 1 and 300.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 29th Oct 2018 16:22
I understand.

Regarding the update, what file should I copy from the template to my current project to make the update?

Program and Core?
www.alexmatei.com
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 29th Oct 2018 18:24
To update an existing project you only need to copy the dll's.

You may need to reload the project in the ide.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 30th Oct 2018 14:44 Edited at: 30th Oct 2018 14:49
Copied the DLLs as shown in the image attached but no difference seems to be. I tried executing the getrawkeystate with the left shift key (since is the new key added) and it didn't worked. I copied the dlls with VS closed.

Should I copy Core?

Thank you!

EDIT: m_panel.Focus() is missing from Core. Should I add it? I have the same problem with the keys not working. (The other ones, not just the one mentioned earlier).
www.alexmatei.com

Attachments

Login to view attachments
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 30th Oct 2018 18:05
Do ALL keys not work? Or only those that have been added since the last AppGameKit update.
I forgot to add the new keycodes.

Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
MateiSoft
11
Years of Service
User Offline
Joined: 22nd Oct 2012
Location:
Posted: 30th Oct 2018 19:53 Edited at: 30th Oct 2018 19:53
All key don't work (checked now, again).

Maybe because that the panel doesn't focus when clicked if you remember the old fix you've made a week ago or so.
www.alexmatei.com
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 30th Oct 2018 20:21
I'll take a closer look tomorrow.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)

Login to post a reply

Server time is: 2024-04-20 05:55:09
Your offset time is: 2024-04-20 05:55:09