Reply to thread
GBAtemp.net - The Independent Video Game Community
Search
Search titles only
By:
Search titles only
By:
Reply to thread
GBAtemp.net - The Independent Video Game Community
Home
Log in
Terms & Rules
Donate
Forums
New posts
Search forums
Groups
Public Events
New
New posts
New resources
New blog entries
New profile posts
New blog entry comments
New threadmarks
Latest activity
Cheats
Cheat Codes Add and Request group
The Legend of Zelda: Tears of the Kingdom cheat codes
Pokémon Legends: Arceus cheat codes
Xenoblade Chronicles 3 cheat codes
Fire Emblem Engage cheat codes
Request a cheat...
Tutorials
Nintendo Switch tutorials
Nintendo 3DS tutorials
Nintendo Wii U tutorials
Reviews
Overview
Official reviews
Downloads
Latest reviews
Search resources
Blogs
New entries
New comments
Blog list
Search blogs
Chat
Top chatters
Search
Search titles only
By:
Search titles only
By:
Log in
Register
New posts
Search forums
Log in
Register
Home
Forums
PC, Console & Handheld Discussions
Nintendo DS
DS Programming for Newbies!
Menu
Install the app
Install
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Foxi4" data-source="post: 4363509" data-attributes="member: 203855"><p>I see what you mean - yes, this is a newbies tutorial and yes, I do owe a clarification.</p><p></p><p>Your approach is interesting since it does have a touch position argument, hence it's practicaly fool-proof. What I meant to say by having touch position global rather than internal, closed in a function was simply a matter of access - if it's locked in a function, it will be available in that function only, unless it is returned. Obviously it cannot be returned since we're already returning something else, plus, the type would be incorrect.</p><p></p><p>I'd rather see Input/Output variables in main merely because these are things that should be accessible anywhere within the program - this nullifies the need of pointing at the values or inputting them as arguments.</p><p></p><p>I'm not saying that every variable should be a global - that's imbalance as well since even if you free() it and even if you are not allocating space to it, it's still there when you're not using it cluttering memory for no reason. I wanted to say that variables, strings and structs used by a myriad of other functions, such as those related to input or those which hold vital data such as graphics should be global due to their nature.</p><p></p><p>It's true that these are very subjective matters and every programmer develops his or her own style as they learn, but it's good to know why some should be global, why some can be local and what are the advantages and disadvantages of both.</p><p></p><p>As for the case of re-declaring touchPosition Touch; each frame, I said that it's wrong merely because it's unnecessary. It leaves a small memory footprint, yes. It takes up less resources than scanning for keys or reading stylus input, yes. Thing is, it's unnecessary.</p><p></p><p>A penny saved is a penny earned, except here, it's in reverse. When you have a little bit of clutter in many areas, altogether it may impact final performace and you may end up between a rock and a hard spot, having to re-code large sections of code just to fix a minor issue, Being tidy is a good thing. <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="wink ;)" loading="lazy" data-shortname=";)" /></p><p></p><p>Young programmers should know even of the smallest things that are wasteful and should be told why. If wastefulness can be avoided, it should be avoided a I'm glad that we're having this discussion here so that they can view it from different angles and I'm glad that you're visiting this thread for proof-reading.</p><p></p><p>So to conclude - when you can make a variable Local, make it Local - it will terminate and flush from memory the moment the function finishes its job and free up resources which can be scarce on platforms like the DS. If you will use a given variable throughout the program multiple times or all the time or if the function is supposed to work in the background, declare it as a Global. If you feel that certain variables should be kept separately in a module-like fashion (about which we will learn later on), keep them in separate, dedicated Header files and include them into your source.</p><p></p><p>Is that acceptable? <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="wink ;)" loading="lazy" data-shortname=";)" /></p></blockquote><p></p>
[QUOTE="Foxi4, post: 4363509, member: 203855"] I see what you mean - yes, this is a newbies tutorial and yes, I do owe a clarification. Your approach is interesting since it does have a touch position argument, hence it's practicaly fool-proof. What I meant to say by having touch position global rather than internal, closed in a function was simply a matter of access - if it's locked in a function, it will be available in that function only, unless it is returned. Obviously it cannot be returned since we're already returning something else, plus, the type would be incorrect. I'd rather see Input/Output variables in main merely because these are things that should be accessible anywhere within the program - this nullifies the need of pointing at the values or inputting them as arguments. I'm not saying that every variable should be a global - that's imbalance as well since even if you free() it and even if you are not allocating space to it, it's still there when you're not using it cluttering memory for no reason. I wanted to say that variables, strings and structs used by a myriad of other functions, such as those related to input or those which hold vital data such as graphics should be global due to their nature. It's true that these are very subjective matters and every programmer develops his or her own style as they learn, but it's good to know why some should be global, why some can be local and what are the advantages and disadvantages of both. As for the case of re-declaring touchPosition Touch; each frame, I said that it's wrong merely because it's unnecessary. It leaves a small memory footprint, yes. It takes up less resources than scanning for keys or reading stylus input, yes. Thing is, it's unnecessary. A penny saved is a penny earned, except here, it's in reverse. When you have a little bit of clutter in many areas, altogether it may impact final performace and you may end up between a rock and a hard spot, having to re-code large sections of code just to fix a minor issue, Being tidy is a good thing. ;) Young programmers should know even of the smallest things that are wasteful and should be told why. If wastefulness can be avoided, it should be avoided a I'm glad that we're having this discussion here so that they can view it from different angles and I'm glad that you're visiting this thread for proof-reading. So to conclude - when you can make a variable Local, make it Local - it will terminate and flush from memory the moment the function finishes its job and free up resources which can be scarce on platforms like the DS. If you will use a given variable throughout the program multiple times or all the time or if the function is supposed to work in the background, declare it as a Global. If you feel that certain variables should be kept separately in a module-like fashion (about which we will learn later on), keep them in separate, dedicated Header files and include them into your source. Is that acceptable? ;) [/QUOTE]
Insert quotes…
Verification
Post reply
Home
Forums
PC, Console & Handheld Discussions
Nintendo DS
DS Programming for Newbies!
General chit-chat
Help
Users
Settings
Notifications
Miscellaneous
Inverse message direction
Display editor on top
Enable maximized mode
Display images as links
Hide bot messages
Hide statuses
Hide chatter list
Show messages from ignored users
Temporarily disable chat
Receive mention alerts
Sound notifications
Normal messages
Private messages
Whisper messages
Mention messages
Bot messages
Desktop notifications
Normal messages
Private messages
Whisper messages
Mention messages
Bot messages
Options
Options
View top chatters
BakerMan
Loading…
I rather enjoy a life of taking it easy. I haven't reached that life yet though.
@
Xdqwerty
:
ok im the host this time
Yesterday at 10:58 PM
@
Xdqwerty
:
https://garticphone.com/en/?c=0013ff1238
Yesterday at 10:58 PM
@
Xdqwerty
:
nobody?
Yesterday at 10:59 PM
@
Xdqwerty
:
ok then no
Yesterday at 11:01 PM
@
Xdqwerty
:
sigh
Yesterday at 11:16 PM
@
Sicklyboy
:
sup nerds
Today at 12:22 AM
@
Xdqwerty
:
@Sicklyboy
, hi
Today at 12:23 AM
@
Sicklyboy
:
How you doin xdq?
Today at 12:30 AM
@
Xdqwerty
:
@Sicklyboy
, not that bad ig
+1
Today at 12:34 AM
@
Sicklyboy
:
Good to hear
Today at 12:38 AM
@
Sicklyboy
:
Lazy day for me. Was gonna go grocery shopping but it's raining so I don't feel like going out. Listened to music and messed with server stuff instead
Today at 12:38 AM
@
Xdqwerty
:
@Sicklyboy
, and i have school tommorrow cuz its sunday
Today at 12:39 AM
@
Sicklyboy
:
I feel that, I got work tomorrow
Today at 12:39 AM
@
Xdqwerty
:
@Sicklyboy
,
atleast you get paid
Today at 12:42 AM
@
Sicklyboy
:
I feel like school, back when I was actually in school, was more entertaining though, because of how much I get to interact with people, hang out with friends, and other stuff like that. All I get to talk to at work is my boring coworkers lol
Today at 12:46 AM
@
Sicklyboy
:
Getting paid is definitely a plus, though
+2
Today at 12:47 AM
@
Psionic Roshambo
:
20 dollars is 20 dollars lol
Today at 12:47 AM
@
Psionic Roshambo
:
https://m.youtube.com/watch?v=6aie4...1dCAyMCBkb2xsYXJzIGlzIDIwIGRvbGxhcnMgbWVtZQ==
+1
Today at 12:49 AM
@
Xdqwerty
:
yawn
Today at 1:16 AM
@
K3Nv2
:
https://youtu.be/sGvT5FKSiyk?si=TYqsdjjbF-4N8Xc8
45 minutes ago
@
BakerMan
:
laye to the paryy?
4 minutes ago
@
BakerMan
:
wow that was my best attempt at typing "late to the party?" with my eyes closed
3 minutes ago
@
BakerMan
:
know what, here's another attempt
3 minutes ago
@
BakerMan
:
laye to the party?
3 minutes ago
@
BakerMan
:
damn
2 minutes ago
Submit
@
BakerMan
:
damn
2 minutes ago
Chat
1