Page 2 of 2
Re: I hate coding with a passion,
Posted: Fri Oct 02, 2009 6:37 am
by Cayle
Jackolantern is spot on. Your problem was not coding, it was coding too soon. When working on the various Angela modules, I design them – TWICE – before coding. I make a design, with all of my classes, attributes, operations and logic flows. In short, I have a program in my head, on paper, or in Visio as in my usual case. Then I try to think of all of the problems with it and fix those problems and come up with a V2 design. I usually code the V2 design. Just remember, there is a 99.999999% chance that you will throw out V1 after you find problems with it. You can either throw out a design, or a lot of code.
D3luxe, not knowing anything about how your tower defense game works, it sounds like you are inadvertently sharing a variable among towers. This easily happens in languages that use pointers. Let me give an example. I’ll create a new variable:
B = 5
Now I’ll create a new one:
A = B
Then I change B:
B = 2
You might expect that A = 5. But if A is not 5, but is actually a “pointer” to the place in memory where the value of B is stored, then what you’ll actually be getting is 2. Different languages behave differently there and have different ways to deal with it.
Re: I hate coding with a passion,
Posted: Sun Oct 04, 2009 6:15 pm
by D3luxe
Cayle wrote:Jackolantern is spot on. Your problem was not coding, it was coding too soon. When working on the various Angela modules, I design them – TWICE – before coding. I make a design, with all of my classes, attributes, operations and logic flows. In short, I have a program in my head, on paper, or in Visio as in my usual case. Then I try to think of all of the problems with it and fix those problems and come up with a V2 design. I usually code the V2 design. Just remember, there is a 99.999999% chance that you will throw out V1 after you find problems with it. You can either throw out a design, or a lot of code.
D3luxe, not knowing anything about how your tower defense game works, it sounds like you are inadvertently sharing a variable among towers. This easily happens in languages that use pointers. Let me give an example. I’ll create a new variable:
B = 5
Now I’ll create a new one:
A = B
Then I change B:
B = 2
You might expect that A = 5. But if A is not 5, but is actually a “pointer” to the place in memory where the value of B is stored, then what you’ll actually be getting is 2. Different languages behave differently there and have different ways to deal with it.
Yes, I know my problems. Like I said, it was more of a learning experience to actually learn the structure of the language rather than to actually make a fully-working amazing game.
And yes, you're somewhat right about the structure of the towers. I am sharing a common variable between them, but not in the sense that you're thinking. I realize that if A = B and i change B, then A changes as well. How I have it though, which is more of me not knowing the language, is I thought how the Child features work in Flash that they would create their own seperate variable, in a sense. Of course I was wrong, but I'm not sure yet if I'll actually be able to save the code I have for the towers or if it would be easier to rewrite them.
Re: I hate coding with a passion,
Posted: Mon Oct 05, 2009 11:18 pm
by Jackolantern
D3luxe wrote:Cayle wrote:Jackolantern is spot on. Your problem was not coding, it was coding too soon. When working on the various Angela modules, I design them – TWICE – before coding. I make a design, with all of my classes, attributes, operations and logic flows. In short, I have a program in my head, on paper, or in Visio as in my usual case. Then I try to think of all of the problems with it and fix those problems and come up with a V2 design. I usually code the V2 design. Just remember, there is a 99.999999% chance that you will throw out V1 after you find problems with it. You can either throw out a design, or a lot of code.
D3luxe, not knowing anything about how your tower defense game works, it sounds like you are inadvertently sharing a variable among towers. This easily happens in languages that use pointers. Let me give an example. I’ll create a new variable:
B = 5
Now I’ll create a new one:
A = B
Then I change B:
B = 2
You might expect that A = 5. But if A is not 5, but is actually a “pointer” to the place in memory where the value of B is stored, then what you’ll actually be getting is 2. Different languages behave differently there and have different ways to deal with it.
Yes, I know my problems. Like I said, it was more of a learning experience to actually learn the structure of the language rather than to actually make a fully-working amazing game.
And yes, you're somewhat right about the structure of the towers. I am sharing a common variable between them, but not in the sense that you're thinking. I realize that if A = B and i change B, then A changes as well. How I have it though, which is more of me not knowing the language, is I thought how the Child features work in Flash that they would create their own seperate variable, in a sense. Of course I was wrong, but I'm not sure yet if I'll actually be able to save the code I have for the towers or if it would be easier to rewrite them.
ActionScript doesn't allow your classes to have individual instance variables? How could someone work around that? Or am I just misunderstanding the problem?
Re: I hate coding with a passion,
Posted: Tue Oct 06, 2009 2:26 am
by D3luxe
Jackolantern wrote:D3luxe wrote:Cayle wrote:Jackolantern is spot on. Your problem was not coding, it was coding too soon. When working on the various Angela modules, I design them – TWICE – before coding. I make a design, with all of my classes, attributes, operations and logic flows. In short, I have a program in my head, on paper, or in Visio as in my usual case. Then I try to think of all of the problems with it and fix those problems and come up with a V2 design. I usually code the V2 design. Just remember, there is a 99.999999% chance that you will throw out V1 after you find problems with it. You can either throw out a design, or a lot of code.
D3luxe, not knowing anything about how your tower defense game works, it sounds like you are inadvertently sharing a variable among towers. This easily happens in languages that use pointers. Let me give an example. I’ll create a new variable:
B = 5
Now I’ll create a new one:
A = B
Then I change B:
B = 2
You might expect that A = 5. But if A is not 5, but is actually a “pointer” to the place in memory where the value of B is stored, then what you’ll actually be getting is 2. Different languages behave differently there and have different ways to deal with it.
Yes, I know my problems. Like I said, it was more of a learning experience to actually learn the structure of the language rather than to actually make a fully-working amazing game.
And yes, you're somewhat right about the structure of the towers. I am sharing a common variable between them, but not in the sense that you're thinking. I realize that if A = B and i change B, then A changes as well. How I have it though, which is more of me not knowing the language, is I thought how the Child features work in Flash that they would create their own seperate variable, in a sense. Of course I was wrong, but I'm not sure yet if I'll actually be able to save the code I have for the towers or if it would be easier to rewrite them.
ActionScript doesn't allow your classes to have individual instance variables? How could someone work around that? Or am I just misunderstanding the problem?
You're misunderstanding the problem I believe. I don't know exactly hwo to explain what I mean, but it doesn't really matter because I was wrong anyway. But yes, classes are allowed to have individual instance variables in AS.