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 / [SOLVED] Types and Functions

Author
Message
sprcoll
11
Years of Service
User Offline
Joined: 26th Aug 2012
Location:
Posted: 7th Oct 2022 19:35
Hello all together, i am training with types and functions, i wan´t do the following and i would be happy if someone helps

The code to train is very simple:



My plan is, that i have the update_players function 1 time and call with the player1 and player2.
The choose values with 1 and 2 works, but the player1 and player2 doens´t work, the sprites are not moving but the compiler don´t give an error.
Is there a way to handle this? This would shorten the code extremely.

Thanks for your help.

The author of this post has marked a post as an answer.

Go to answer

Dark Raven
9
Years of Service
User Offline
Joined: 27th Jul 2014
Location: United States
Posted: 7th Oct 2022 21:37
It looks like the problem is your are increasing the posx of d and then calling the setspriteposition on the original posx and posy of the players as they aren't being changed. What you might try doing is possibly set d as ref cause I think d is creating a copy of player type and not a reference to the original variables so nothing is getting updated so that may be why the sprites are moving. Then again not tested so can't be sure but you might try changing "d as player" to d ref as player" and see what happens.
Arch-Ok
AGK Developer
4
Years of Service
User Offline
Joined: 11th Jul 2019
Location: Bursa/TÜRKIYE
Posted: 7th Oct 2022 22:13
This post has been marked by the post author as the answer.
you must use reference of player
at the function definition try this;

sprcoll
11
Years of Service
User Offline
Joined: 26th Aug 2012
Location:
Posted: 9th Oct 2022 17:21
Thanks for your help this works.

Login to post a reply

Server time is: 2024-03-29 05:29:12
Your offset time is: 2024-03-29 05:29:12