46
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Although I think an array of a small class is the best solution, I usually just end up using an array of integers. Something like:
int map[80][25][3];
With the 3rd dimension being: 0 - Character 1 - Type (Usually just wall/floor) 2 - Misc (color, seen before, etc.). But really, I've regretted doing this in every long term project I've done it in. It's much more convenient to use a class.
Just gotta keep at it bit by bit until it looks about right to ya. Perhaps some other Delphi folk will pop around once it is up and illuminate some bits on it.
I started this earlier today, trying to make a <1/2KBRL. I didn't succeed. By the time I was done, I had a roguelike which took 7 and a half hours, and was 4.4KB in source code size. So it's a <5KBRL which is just as fine with me. Since it was done in 7 and a half hours, it's also an 8HRL I suppose.
It's pretty simple, you are Beowulf, diving through Grendel's lake to kill Grendel's mother at the bottom. You have a limited amount of health, and there is no leveling. The goal is to reach the bottom of the lake (Level 8 ) and kill Grendel's mother. Pretty simple, but it has a nice dungeon generator. I'm happy with it!
It's only story is various text quoted from Beowulf.
You can download it here:
http://code.google.com/p/dreamhack/downloads/list
Yet another option: don't use classes at all, use a set of structs for each item type, and a super-struct that contains a simple id flag, and a union of each struct type. The amount of memory you take up in the union will be the amount the of the largest struct.
I assume that DURATION_MIGHT_POTION is either an even number from 2 to 100, or an odd number between 51 and 199, since otherwise MightPotionTick might be called not exactly once... That's very bug-prone.
Sorry, I don't understand exactly what you mean.
I just found another bug... in MightPotionTick, you probably want to call "Player.Strength := Player.Strength - 5" only if DrinkMightPotionEvent.Progress = 50?
Suppose that yes, and that DURATION_MIGHT_POTION is 35, then MightPotionTick will be called for the following values of progress: 0 2 5 8 11 14 17 20 22 25 28 31 34 37 40 42 45 48 51 54 57 60 62 65 68 71 74 77 80 82 85 88 91 94 97 100. That means that Progress will never be 50, and player strength will never be reduced by 5 by that method, thus the player will have his strength permanently increased by 5 after drinking the potion.
And if DURATION_MIGHT_POTION is, say, 200, then he will have his strength permanently decreased by 5. The problem is with low granulaties. Sorry if I misunderstood something.
I assume that DURATION_MIGHT_POTION is either an even number from 2 to 100, or an odd number between 51 and 199, since otherwise MightPotionTick might be called not exactly once... That's very bug-prone.
Why give the events the parameter 'turns' if you are then accessing the original timer object instead of using this parameter?
What if the player drinks a new potion of might while the old one was still active? It seems hard to do correctly in your current way. If you don't implement this case specially, the strength bonus of the old one will remain in action forever.
I don't think that the abstraction of timer you did is helpful in this case at all. Your implementation of the potion of might is not simpler than just having a MightTimer:integer property, which is decreased on each turn (if >0), increased on drinking, and a method called on each change (note that this implementation would also be better because the problem with drinking multiple potions it solved more easily).
If you now want to create a Potion of Agility, you will have to repeat a lot of functionality, and in many places. Abstraction is helpful if it makes doing many similar things easier and without repetitions, and I think this goal is not achieved in this case.
Instead ofCode: [Select]begin
Percentage := FTimerDurationLeft / FTimerDuration;
Result := Trunc(Percentage * 100);
end;
why not just Result := (FTimeDurationLeft * 100) div FTimerDuration? You don't need doubles for this calculation...