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 / Please Check this code

Author
Message
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 29th Feb 2016 19:22
Hi.

I wrote a code for my character that can shoot bullet. but sometimes it don't shoot any bullet. if possible please check this code is right or i'm wrong.



Thanks.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 1st Mar 2016 09:07
Here are a few pointers...

1) You use setfolder, but don't return the folder, so every time you shoot a bullet, you're trying to add \media\images\items\ to the current path. (So after 3 bullets, the current virtual working folder will be 'media\images\items\media\images\items\media\images\items\' which is obviously wrong.) At the end of the function, include a SetFolder( "" )

2) You're using '\' when you should be using '/' in SetFolder.

3) You don't specify if P_BuilletNumber is global, therefore may always be 0.

4) You don't specify if P_MaxBuillet is global, therefore may always be 0.

5) You don't specify if EmptySpr is global, therefore may always be 0.

6) Missing '/' from start of "bullet.png"

7) You don't specify if BulletImg is global, therefore may always be 0.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 1st Mar 2016 17:16 Edited at: 1st Mar 2016 17:32
Thanks Mobiius for Guide.

Quote: "1) You use setfolder, but don't return the folder, so every time you shoot a bullet, you're trying to add \media\images\items\ to the current path. (So after 3 bullets, the current virtual working folder will be 'media\images\items\media\images\items\media\images\items\' which is obviously wrong.) At the end of the function, include a SetFolder( "" )"


Ok, I added SetFolder( "" ) at End My Function like below:



Quote: "2) You're using '\' when you should be using '/' in SetFolder."

Ok, change Backslash to Slash like below code:



Quote: "3) You don't specify if P_BuilletNumber is global, therefore may always be 0.

4) You don't specify if P_MaxBuillet is global, therefore may always be 0.

5) You don't specify if EmptySpr is global, therefore may always be 0."


Why I can't use global for them?
currently I changed to local instead global.
basically when I can't use global variables?


Quote: "6) Missing '/' from start of "bullet.png""


when I sue backslash before bullet.png, it don't show.



but when I use "/" in SetFolder("/media/images/items/") instead of first "bullet.png" , it show Image.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 1st Mar 2016 20:47
Quote: "Why I can't use global for them?"
You can. You misunderstood what Mobiius said.
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 1st Mar 2016 23:42
Quote: "Quote: "Why I can't use global for them?"
You can. You misunderstood what Mobiius said."

This. You CAN use globals, I was commenting that you didn't say that you were in the code provided.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 2nd Mar 2016 05:12
Quote: "You can. You misunderstood what Mobiius said.
"

Quote: "This. You CAN use globals, I was commenting that you didn't say that you were in the code provided."


sorry, I mistake.

if there is any problem I ask here.

Thanks.

Login to post a reply

Server time is: 2024-11-25 10:00:14
Your offset time is: 2024-11-25 10:00:14