This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's Your Projects subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. Project Ideas/Start New Projects => Your Projects
Author Message
Flameviper


Advanced Newbie


Joined: 05 Jun 2008
Posts: 62

Posted: 25 Jul 2008 02:23:15 pm    Post subject:

Have you ever seen one of those tower defense games?
They're basically street-map-type paths through a grid, on which enemies travel.
You can put "towers" in spaces on this grid, which will automatically shoot at the enemies as they go through. You get a limited amount of lives and there are several types of towers, all of which have upgraded forms.

Here are some examples.

Vector TD

Vector TD 2

I think a tower defense game in Asm (or, God help us, TI-BASIC) would be farging awesome.

Could someone look into doing this, if it's even possible?
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 25 Jul 2008 02:29:51 pm    Post subject:

It's been suggested before.
Back to top
Flameviper


Advanced Newbie


Joined: 05 Jun 2008
Posts: 62

Posted: 25 Jul 2008 05:34:55 pm    Post subject:

I think it's awesome enough of an idea to be suggested twice. And nobody picked it up the first time, so maybe another suggestion would prompt someone to start the project.

Last edited by Guest on 25 Jul 2008 05:40:26 pm; edited 1 time in total
Back to top
Flameviper


Advanced Newbie


Joined: 05 Jun 2008
Posts: 62

Posted: 01 Aug 2008 04:54:14 pm    Post subject:

Sorry again about double-posting, but I've actually made some progress on the game.

Not much of a UI yet (I do that last) but it can now form a grid and a limited-range cursor which is controlled by the arrow keys. It uses Pxl-change to display itself so it doesn't blot out whatever's behind it.

For the enemies, I'm going to use L1 in the format {X location, Y location, current health, full health}. When they die I'm not going to remove them from the set (way too messy); whenever an operation includes them, I'll simply set it to skip ones where the third variable is zero (this includes tower targeting, checkpoint at the end to take away points for missed enemies, and displaying).

For the towers themselves, I'll probably have 3 kinds: Fast/weak (thunder), strong/slow (fire), and one that does no damage but slows the enemy (ice). Thunder will be stored in L2, fire in L3, and ice in L4 as {X location, Y location, level, energy ...}. Each type will have its own cycle where they check to see if enemies are in radius, and if they are, they'll subtract some HP. The energy for the types will be subtracted every turn, when it attacks the energy will go back up to 1/3/5 depending on the type, and while the energy does not equal zero it will skip attacking for that unit.

I don't know if the towers are going to have any AI and aim specifically for targets or just choose the first one that comes up during a scan. I do, however, know that using the Pythagorean theorem for 3 different lists comparing to 10 enemies each, is going to take a long-a time.

EDIT: I could just take the cheap way out and have square radii for the towers, but would that be cutting corners or acceptable optimization?

EDIT 2: I've come up with a save system. Instead of using letter variables for the time, money etc, it will be stored in a list (L6). If you pressed the SAVE button, it would store the contents of the current game's lists as LTDSAV (for the time/money/score), LTDSV1 (enemies), LTDSV2 (towers 1), LTDSV3 (towers 2), and LTDSV4 (towers 3) and archive it. The script before the main menu would reset all the normally used lists in the game. NEW GAME wouldn't do anything except run off a blank list, RESUME would unarchive the save files, convert them to the regular files, rearchive them and start the same cycle, and ERASE SAVE would unarchive save files/wipe them/rearchive them and return to the home screen.


Last edited by Guest on 01 Aug 2008 05:18:35 pm; edited 1 time in total
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 01 Aug 2008 05:16:02 pm    Post subject:

Well, one easy optimization is to just square both sides. Instead of checking if √(X^2+Y^2)<3 (or whatever it comes to be), check if X^2+Y^2<9.
Back to top
Flameviper


Advanced Newbie


Joined: 05 Jun 2008
Posts: 62

Posted: 01 Aug 2008 05:22:07 pm    Post subject:

DarkerLine wrote:
Well, one easy optimization is to just square both sides. Instead of checking if √(X^2+Y^2)<3 (or whatever it comes to be), check if X^2+Y^2<9.
[post="125689"]<{POST_SNAPBACK}>[/post]


Well, this helps. However in GRAPH-PRIX the only way I could think of to trace collisions with the circular obstacles was this monstrosity, where X is object-X, Y is object-Y, V is circlecenter-X and W is circlecenter-Y.

If X>V
X-V->T
If V<X
V-X->T
If Y>V
Y-V->U
If Y<V
V-Y->U
And then do the calculation with T and U for the distances. Is there another, non-code-hell way to do this?
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 01 Aug 2008 05:56:01 pm    Post subject:

abs(X-V)->T
abs(Y-W)->U

But if you're squaring them, the sign doesn't matter anyway.


Last edited by Guest on 01 Aug 2008 05:56:26 pm; edited 1 time in total
Back to top
Liazon
title goes here


Bandwidth Hog


Joined: 01 Nov 2005
Posts: 2007

Posted: 01 Aug 2008 06:16:23 pm    Post subject:

will you use xlib for anything?
Back to top
Flameviper


Advanced Newbie


Joined: 05 Jun 2008
Posts: 62

Posted: 01 Aug 2008 06:26:11 pm    Post subject:

Quick update: I've written the basic engine for the movement of enemies across the map. They follow the path in sequence perfectly but it's a MASSIVE memory drain with 10 enemies. I'll upload the current program later but I don't know if this can even be fixed. Plus there's the tower radius-scan for every tower/enemy combination which will undoubtably slow it down at least three times that much, so...
Back to top
Flameviper


Advanced Newbie


Joined: 05 Jun 2008
Posts: 62

Posted: 02 Aug 2008 11:57:54 am    Post subject:

Okay, I give up. It keeps giving me a dimension error for absolutely no reason, and I've had it with this program. If anyone else wants to try fixing it, go right ahead.
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 02 Aug 2008 12:20:09 pm    Post subject:

Not sure if you knew this already, but...

    If condition
    command:command


...does not serve as a replacement for:

    If condition
    Then
    command
    command
    End


That is, a newline in the middle of a line is still interpreted as though it were on the next line.


Last edited by Guest on 30 Jul 2010 05:14:19 am; edited 1 time in total
Back to top
Flameviper


Advanced Newbie


Joined: 05 Jun 2008
Posts: 62

Posted: 02 Aug 2008 01:05:46 pm    Post subject:

I see. But is there any way to optimize the program right now? Because it's running slower than molasses in January.


Code:
:Lbl AA
:50→dim(L1
:50→dim(L2
:50→dim(L3
:50→dim(L4
:50→dim(L5
:10→dim(L6
:Fill 0,L1
:Fill 0,L2
:Fill 0,L3
:Fill 0,L4
:Fill 0,L5
:Fill 0,L6
:0→Xmin
:0→Ymin
:95→Xmax
:62→YMax
:ClrDraw
:ClrHome
:0→S
:0→T
:0→U
:0→V
:0→W
:0→X
:0→Y
:0→Z
:Menu("TI.TD V0.25","NEW GAME",BA,"RESUME",AC,"ERASE SAVE",AD,"CREDITS",AB
:Lbl AC
:Lbl AD
:Lbl AB
:ClrDraw
:Text(0,0,"TI-TOWER DEFENSE BETA V0.1"
:Text(6,0,"BY AEROMAX/FLAMEVIPER
:Text(12,0,"AUGUST 1, 2008. UPLOADED TO"
:Text(18,0,"UNITED-TI.ORG FORUMS AS"
:Text(24,0,"INCOMPLETE WORK. EXPECT"
:Text(30,0,"COMPLETION BY SEPTEMBER."
:Text(36,0,"ALL RIGHTS RESERVED.
:0→θ
:Repeat θ≠0
:getKey→θ
:End
:ClrHome
:ClrDraw
:Goto AA
:Lbl BA
:0→T
:Text(0,0,"-----"
:Line(20,55,20,62
:For(θ,0,55,5
:Line(0,θ,80,θ
:Line(85,θ,95,θ
:End
:For(θ,0,95,5
:Line(θ,0,θ,25
:Line(θ,30,θ,40
:Line(θ,45,θ,55
:End
:For(θ,70,80,5
:Line(θ,6,θ,9,0
:End
:For(θ,10,25,5
:Line(69,θ,66,θ,0
:End
:For(θ,70,90,5
:Line(θ,29,θ,26
:End
:For(θ,0,5,5
:Line(81,θ,84,θ
:End
:For(θ,45,55,5
:Line(81,θ,84,θ
:End
:Line(85,41,85,44
:Line(90,41,90,44
:For(θ,1,54,1
:Line(θ,1,θ,14,0
:End
:For(θ,1,4,1
:For(W,51,54,1
:Pxl-Change((62-W),θ
:End
:End
:0→X
:55→Y
:Goto BB
:Lbl BZ
:L6(1)+.33→L6(1)
:Text(0,0,(iPart(L6(1)))
:getKey→Z
:If Z=0
:Goto BC
:X→U
:Y→V
:If Z=24 and X>0
:X-5→X
:If Z=25 and Y<55
:Y+5→Y
:If Z=26 and X<90
:X+5→X
:If Z=34 and Y>0
:Y-5→Y
:For(θ,(X+1),(X+4),1)
:For(W,(63-Y),(66-Y),1)
:Pxl-Change(W,θ
:End
:End
:For(θ,(U+1),(U+2),1
:For(W,(V-2),(V-1),1
:Pxl-Change((62-W),θ
:End
:End
:Goto BC
:Lbl BB
:For(θ,5,50,5)
:(θ*2)→Z
:(0-Z)→L1(θ-4)
:44→L1(θ-3)
:L1(41)→L1(θ-2)
:L1(41)→L1(θ-1)
:0→L1(θ)
:End
:Lbl BC
:L1→L2
:For(θ,5,50,5)
:Line(L2(θ+1),(L2(θ+2)-2),(L2(θ+1)+3),(L2(θ+2)-2),0
:If L1(θ+5)<81
:L1(θ+1)+1→L1(θ+1):L1(θ+5)+1→L1(θ+5)
:If L1(θ+5)≥81 and L1(θ+5)<116
:L1(θ+2)-1→L1(θ+2):L1(θ+5)+1→L1(θ+5)
:If L1(θ+5)≥116 and L1(θ+5)<131
:L1(θ+1)-1→L1(θ+1):L1(θ+5)+1→L1(θ+5)
:If L1(θ+5)≥131 and L1(θ+5)<151
:L1(θ+2)+1→L1(θ+2):L1(θ+5)+1→L1(θ+5)
:If L1(θ+5)≥151
:L1(θ+1)-1→L1(θ+1)
:Line(L1(θ+1),(L1(θ+2)-2),(L1(θ+1)+3),(L1(θ+2)-2)
:End
:Goto BZ


Last edited by Guest on 02 Aug 2008 03:44:33 pm; edited 1 time in total
Back to top
cjgone
Aw3s0m3


Active Member


Joined: 24 May 2006
Posts: 693

Posted: 02 Aug 2008 01:21:31 pm    Post subject:

Uh, don't use 'goto' and 'labels'?
Back to top
WikiGuru
ADOS (Attention deficit... Oh! Shiny!)


Elite


Joined: 15 Sep 2005
Posts: 923

Posted: 02 Aug 2008 02:06:58 pm    Post subject:

quick comments:

Quote:

Code:
:50→dim(L1
:50→dim(L2
:50→dim(L3
:50→dim(L4
:50→dim(L5
:10→dim(L6
:Fill 0,L1
:Fill 0,L2
:Fill 0,L3
:Fill 0,L4
:Fill 0,L5
:Fill 0,L6
:0→Xmin
:0→Ymin
:95→Xmax
:62→YMax
:ClrDraw
:ClrHome
:0→S
:0→T
:0→U
:0→V
:0→W
:0→X
:0→Y
:0→Z


change this to


Code:
:DelVar SDelvar TDelvar UDelvar VDelvar WDelvar XDelvar YDelvar ZDelvar L1Delvar L2Delvar L3Delvar L4Delvar L5Delvar L650->dim(L1
:50->dim(L2
:50->dim(L3
:50->dim(L4
:50->dim(L5
:10->dim(L6
:0→Xmin
:0→Ymin
:95→Xmax
:62→YMax


Quote:

Code:
:0→θ
:Repeat θ≠0
:getKey→θ
:End


remove the 0->θ, it's unnecessary.

Also, anytime you want to store zero to a letter variable, just delete it using DelVar.

Another note, when comparing with 0, just use logic:
If Z is the same as If Z=0
If Not(Z is the same as If Z!=0


Last edited by Guest on 30 Jul 2010 05:14:39 am; edited 1 time in total
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 02 Aug 2008 04:54:02 pm    Post subject:

WikiGuru wrote:
Another note, when comparing with 0, just use logic:
If Z is the same as If Z=0
If not(Z is the same as If Z≠0
[post="125708"]<{POST_SNAPBACK}>[/post]
You've got those backwards. There's an implied ≠0 in each If check.

Last edited by Guest on 30 Jul 2010 05:13:46 am; edited 1 time in total
Back to top
WikiGuru
ADOS (Attention deficit... Oh! Shiny!)


Elite


Joined: 15 Sep 2005
Posts: 923

Posted: 02 Aug 2008 08:26:02 pm    Post subject:

Oh, doh. I knew that. My stupid boolean logic has failed me.
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement