forums

TNT Basic Forums > Games In Progress
Am working on a space RTS
< Last Thread     Next Thread >
Author
Thread        Post A Reply

10-01-2006 14:36

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

source: www.geocities.com/appleide/Inter-PlanetaryWarfare.tbproj.zip

Please comment!

-> only download on condition that:
-I am not held responsible if the file breaks your computer.
-you may not use this for any commerical purpose
-you may modify this as much as you like.
-acknowledge that the images of space shuttle and satellite are in public domain, because they were released by NASA.
-the planet is made by program PLANETFORGE v2.0 by Bryce.his email: pfhelp AT hotpop DOT com.NOSPAM
-starfield code from pong tutorial

(Just in case ;))

10-01-2006 14:41

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

oh yeah, the controls.. ;)
Upon launch:
click preference, go to userpreferences/interplanetarywarfare/resolutions/
and select a resolution that suits you.

Click new game

wait 5 seconds.

Then...

GAME:
click and drag to select a unit.
Command-click to send the unit to where you mouse clicked.
use arrow keys to scroll on the 5000x5000 pixel map.

10-02-2006 06:56

Posted by:
Orteil

Location:
Somewhere in France

Find more posts by Orteil

OK, I downloaded the file, then StuffItExpander told me that it encountered an "unknown file type" or something.
I had a folder named Inter-PlanetaryWarfare.tbproj; inside of it is another folder (named Basc) and again inside of it is something named "128 - Eric" that looks like a text file but when opened with SimpleText I can't see anything inside...

Well, how do I open that now ?
And it's the same thing with the most of the source codes I downloaded on this site by the way...
(it seemed to be a nice game anyway)

10-02-2006 08:59

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

try getting mac os x.... ? I zipped it with Mac OS X.

10-02-2006 13:09

Posted by:
Orteil

Location:
Somewhere in France

Find more posts by Orteil

Arhaharh, say that to my father !
*dreams of Mac OS 10*

10-02-2006 13:13

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

its like... 5 years already...


Anyways... just get a job at maccas. Working 10 hours a week for 16 weeks or so and you can get your self a shiny new macbook. (get 1gb memory too. It'll be cheap if you go to university, because you get discount 10% on the whole computer, otherwise, you'll get 6% off, because it is part of the employees benefits program. all mac donalds employees get 6% off apple products).

Thats what I did.

10-02-2006 13:14

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

also.. check if the sourcecode that work end in "tbproj"

if not, post here, and I try to make it work for you.

10-02-2006 13:15

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

I meant, if it works, not "if not"....

10-02-2006 13:15

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

uhh...
I mean "if it is"... not "if it works"



damn no editing...

10-02-2006 23:15

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

.tbproj bundles are mac os x only, however if your save your game as the older resource file format it will work on os 9.

10-03-2006 00:19

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

www.geocities.com/appleide/game.rsrc.zip

10-03-2006 01:02

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

BTW the game looks nice, you made great efforts for code clarity (which is very good point) but it is very innefficient, making it very slow

(please note that i didn't study the code in depth so i may be wrong... besides that don't feel like i'm telling you what to do, i'm just giving a few tips to improve performance =) )

just check the following things:

- you have a possiblity of 1000 units. Right now, you,re checking for 1000 units even when there are only 2-3, slowing things down a lot.
- i think you're calling 'draw frame' more than once per frame.
- look at code like that:

for n=0 to 999
selected[n]=0'reset selection
next n

for n=0 to 999
if (currentx[n]>startx AND currentx[n]<endx) OR (currentx[n]<startx AND currentx[n]>endx) 'if unit is within boundary...
if (currenty[n]>starty AND currenty[n]<endy) OR (currenty[n]<starty AND currenty[n]>endy)
selected[n]=1'set its selection property to true.
end if
end if
next n

the the 'for' are exactly the same... you could combine them:

for n=0 to 999
selected[n]=0'reset selection
if (currentx[n]>startx AND currentx[n]<endx) OR (currentx[n]<startx AND currentx[n]>endx) 'if unit is within boundary...
if (currenty[n]>starty AND currenty[n]<endy) OR (currenty[n]<starty AND currenty[n]>endy)
selected[n]=1'set its selection property to true.
end if
end if
next n

- now look at this part:
for n=0 to 999
currentx[n]=sprite x(sprite[n]) 'records the position of every unit
currenty[n]=sprite y(sprite[n])

it records the position of 1000 sprites EVERY FRAME.

instead of giving a value to the sprite, getting it back, modifiying, giving it again, getting it back, etc. i think it would be better to either keep the locations in variables and not fetch'n'give them every frame, either use moan and don't work with positions at all. TYhe thing is, you,re already using arrays to store the locations, so there is no use getting them back from the sprite every frame. (Fetching back/forward 2000 variables every frame can surely slow things down.) hope i'm not too confusing on this part

10-03-2006 01:13

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

Thanks very much!!!

(as you know... I am changing my code to resizable arrays. that way, there will be no limit in number of units!)

also, I thought I needed to track every single object because I think I will introduce items like "guidance missile"..

I'll take note of the tips you gave me. :)

10-03-2006 01:15

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

what i meant is that instead of:

sprite 0,currentX+5,y,1
...
currentX = sprite x(0)


you can use:

currentX=currentX+5
sprite 0,currentX,y,1

this way no need to take back positions all the time.

10-03-2006 01:16

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

Oooo.... thanks

10-03-2006 01:28

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

I've just finished converting to the "resizing arrays" thing.

there is only less than 30% speed improvement... really shows my code is inefficient in all other aspects too.... :(

10-03-2006 01:34

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

TNT is not that fast either, and offers few ways for performance tuning

but looking at not iterating in for loops to often, not using draw frame more than once per frame, etc. can only help.

And 30% speed improvement in the programming world is huge =)

Apart than that you could post the new code and i could take a quick look if i see some other obvious problems

but of course you can't expect to do in tNT what you'd do in C

10-03-2006 01:39

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

I just noticed... the "dragging mouse to form rectangle thing" drops framerate by over 50%.

procedure PlayerSelect()
int startx,starty,endx,endy 'the variables for boundaries of selection box created by mouse.
startx=mouse x+Viewport X offset(2) 'start, is the spot where mouse has clicked on the map.
starty=mouse y+Viewport Y offset(2)
canvas 2
int n
if NOT pressed (55) 'if player isn't issuing a command...
while mouse button' and the player is click-dragging the mouse...
copy canvas 3 to 2 'copy the canvas, to remove old rectangles
set pen color blue'set to blue
endx=mouse x+Viewport X offset(2)'the end points are where mouse is
if mouse y<resolutionheight-(100*resolutionheight/480) 'if mouse is below viewport, set box edge to boundary of viewport, not into the gray rectangle
endy=mouse y+Viewport Y offset(2)
else
endy=resolutionheight-(100*resolutionheight/480)+Viewport Y offset(2)-1
end if
Frame Rect startx,starty to endx,endy'draws the selection rect
draw frame'draw frame
for n=0 to numberofunits-1
selected[n]=0'reset selection
if (currentx[n]>startx AND currentx[n]<endx) OR (currentx[n]<startx AND currentx[n]>endx) 'if unit is within boundary...
if (currenty[n]>starty AND currenty[n]<endy) OR (currenty[n]<starty AND currenty[n]>endy)
selected[n]=1'set its selection property to true.
end if
end if
next n
wend


endx=startx'reset these variables
endy=starty
end if
copy canvas 3 to 2'refresh screen to clear the selection rects
draw frame'draw frame
end proc

10-03-2006 01:41

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

Can't wait to do the particle system I had done before!!! hehehe.

10-03-2006 01:50

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

looking at this rectangle code...

firstly there is a 'draw frame' command. i'm not seeing your whole code, but i'm not sure it is really necessary?

and second i think i found another thing that slows down your game A LOT, and this time it's not your fault even thought there are workarounds.

TNT is very slow at drawing. So copying canvases around, drawing rectangles, and all that stuff everyframe slows a lot. I suspect copying the whole canvas is the one operation that slows things down the most. Usually in TNT, it's best you draw a background and then touch it no more. Sprites are much faster.

10-03-2006 01:52

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

Thats the only draw frame command I got left... If I remove it, the rectangle doesn't draw.

10-03-2006 01:54

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

ok.. then i'm pretty sure it's copying/drawing whole canvases

10-03-2006 02:13

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

what about getting an image of a "frame rectangle", and scaling it instead of drawing one?

10-03-2006 13:29

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

that would probably be faster, if it does not require you to redraw the background.

I don't remember if the star background scrolled or not? If it doesn't scroll then surely you should avoid drawing on it at any cost

10-03-2006 23:47

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

Its a 2000x2000 sized starfield, so yes, it scrolls

10-03-2006 23:49

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

I am having trouble to get particles to keep moving after they reached their target... Right now, when a bullet is fired, it stops after it reached where the enemy used to be. And then it does not disappear, because I've made the particles to disappear after a certain distance.

10-04-2006 00:20

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

>>
Its a 2000x2000 sized starfield, so yes, it scrolls
>>

Ok... then it's going to be slow. Is there a way you could convert it to a viewport map? maybe then you could get better speed (if of course it matters to you)

>>
I am having trouble to get particles to keep moving after they reached their target... Right now, when a bullet is fired, it stops after it reached where the enemy used to be.
>>

I don't know how you programmed things so i can only guess. The bullet probably stores a target position? If then you should update the target position as the enemy moves, or, better, have a target sprite rather than a target position.

>>
And then it does not disappear, because I've made the particles to disappear after a certain distance.
>>

Sorry, i don't understand what you mean! Just remove sprites you need no more with 'sprite off'?

10-04-2006 07:17

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

I mean, like, in a straight line.

10-05-2006 01:07

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

here is the source

http://geocities.com/appleide/game.rsrc.zip


I mean... Move in a straight line infinitely, do not stop until it hhas moved a certain distance. This is how I want my bullets to behave. but I can't make it work...

10-05-2006 22:57

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

Could you explain more what doesn't work, what steps to do to see the bug, what you expect? i looked at it but didn't see anything obviously wrong

BTW speed has improved A LOT =) Before it was unplayable

10-06-2006 00:18

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

It was always playable... on my macbook.

What computer do you use?

Try selecting the space shuttle and when the satellite moves, command clicking the satellite.

You will fire at it, but when your bullets disappear when they reach where the satellite used to be, and not keep going.

10-06-2006 00:50

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

i couldn't reproduce it exaclty as you said becuase that space thing wouldn't move

but i saw some shots stop at the wrong place

now i don't intend to study the code in depth so i could make wrong assumptions.

look at this:

particledirx[numberofparticles-1]=currentx[tenemy]
particlediry[numberofparticles-1]=currenty[tenemy]

you make the particle aim at a certain location. if the enemy moves, the particledirx/y variables don't move along the enemy.

then you write:

if particlex[n]=particledirx[n] AND particley[n]=particlediry[n]
sprite off particlesprite[n]
particleexists[n]=0
end if

this means, when the particule arrives at the location where the enemy was first, kill it. That's exactly what's happening. You want to kill the particle when it collides with the enemy. particledirx should indicate only a direction, no destination.

10-06-2006 00:51

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

"What computer do you use?"

eMac G4 1 Ghz

(and always at least ten apps open at once :P)

10-06-2006 01:10

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

To control the spaceship:
click and drag across the screen as you would select a file on the desktop. The ship with the green square is the one you can control.
Command click some where on the map.
THe ship will rotate and go there.


"this means, when the particule arrives at the location where the enemy was first, kill it. That's exactly what's happening. You want to kill the particle when it collides with the enemy. particledirx should indicate only a direction, no destination."

Umm, I was killing the particle so that it disappears when it stops, so take that line of code off.

And it stops prematurely.

I will explain it.

THe ship aims at the enemy.
Fires
The bullet should go in the same direction until it collides or has moved a certain distance.

Also, can't you command the ship to move?
If you can, bring him down to middle of the map; the satellite will follow you. Now, shoot at the satellite.

Something weird happens.

10-06-2006 01:28

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

>>
To control the spaceship:
click and drag across the screen as you would select a file on the desktop. The ship with the green square is the one you can control.
Command click some where on the map.
THe ship will rotate and go there.
>>
No, i meant my opponent almost never moved, or moved very shortly, so it was impossible to test. Though you explained to go to the middle of the map, i could try that. And, BTW on my computer, the spaceship doesn't rotate when it moves.

>>
Umm, I was killing the particle so that it disappears when it stops, so take that line of code off.

And it stops prematurely.
>>

Very bad. If you have code you don't use anymore, you should really take it off! this code meant to remove the particle when it reaches its initial goal.

And, in the part that removes particles (with sqrt) you probably want to do 'sprite off particlesprite[n]' so that it actually gets removed from the screen.

and where is the code to make the opponent and the particles colldie? i couldn't find it

10-06-2006 01:29

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

(for the rotating ship isse: change window mode for window mode hardware)

10-06-2006 01:31

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

forget my comment about using 'sprite off' i saw all unused particules are auto deleted

10-06-2006 01:32

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

just saw something weird...

for n=0 to numberofparticles-1
if n<>0

... particle code...

end if
next n

does that mean particle #0 is never processed?

10-06-2006 01:40

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

That was a hack.


Some how particle 0 is the shuttle.

10-06-2006 01:42

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

I havent made the collide code yet.

They still can't shoot properly, how can I put it in?

10-06-2006 01:44

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

>>
And, in the part that removes particles (with sqrt) you probably want to do 'sprite off particlesprite[n]' so that it actually gets removed from the screen
>>

I have got this section of code that automatically removes the sprites if particleexists=0...

10-06-2006 01:45

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

don't make the space ship be a particle... meaningless stuff like that makes code harder to debug!

but i think i found the error:

move sprite particlesprite[n],particledirx[n]-particlex[n],particlediry[n]-particley[n],5'ptypespeed[n]

this is MOAN. and you call it everyframe. Moan isn't supposed to be called every frame, you,re supposed to call the command once and then let it go.

IMHO moan is a nice toy for beginners but when it comes to serious stuff i would never work with it (NOTE: some people might tell you the opposite. This is just my opinion. However, by moving the sprites yourself, you're out out of the quirks of moan for sure)

10-06-2006 01:45

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

>>
>>
And, in the part that removes particles (with sqrt) you probably want to do 'sprite off particlesprite[n]' so that it actually gets removed from the screen
>>

I have got this section of code that automatically removes the sprites if particleexists=0...

>>
Didn't see your later comment ...

10-06-2006 01:46

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

>>
don't make the space ship be a particle... meaningless stuff like that makes code harder to debug!

but i think i found the error:

move sprite particlesprite[n],particledirx[n]-particlex[n],particlediry[n]-particley[n],5'ptypespeed[n]

this is MOAN. and you call it everyframe. Moan isn't supposed to be called every frame, you,re supposed to call the command once and then let it go.

IMHO moan is a nice toy for beginners but when it comes to serious stuff i would never work with it (NOTE: some people might tell you the opposite. This is just my opinion. However, by moving the sprites yourself, you're out out of the quirks of moan for sure)
>>


How should I go about it?

10-06-2006 01:49

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

and i also notice you divided the code into lots of procedures, but inside each procedure there are very few comments explaining what things do. For example, i should have found a 'remove particle when it's too far away' comment at the sqrt part, etc.

write code as though you srite it for someone else than you. It will help you find bugs, because you're not a computer, so code errors don't jump into your face, hoever if comments in english reflect the general unfolding of the program, you might notice logical errors. Also, if you make a big game in many weeks/months, in the end you may not remember what this and that was for precisely.

Just to help =)

10-06-2006 01:49

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

Mind if I add you on msn?

These forums are so.... *lost for words*

I didn't make the ship a particle, but some how it is.

10-06-2006 01:50

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

You should go about it by using 'sprite' directly. Simply use ssome maths to progressively move the x and y values towards aim_x and aim_y. (if you need further help... i don't know what you don't know how to do)

10-06-2006 01:50

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

yeah you can add me no problem

10-06-2006 01:51

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

*and i also notice you divided the code into lots of procedures, but inside each procedure there are very few comments explaining what things do. For example, i should have found a 'remove particle when it's too far away' comment at the sqrt part, etc.

write code as though you srite it for someone else than you. It will help you find bugs, because you're not a computer, so code errors don't jump into your face, hoever if comments in english reflect the general unfolding of the program, you might notice logical errors. Also, if you make a big game in many weeks/months, in the end you may not remember what this and that was for precisely.

Just to help =)*

I write comments after I have got it working... it isn't working right now... so.
I 'll add some comments now.

10-06-2006 03:23

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

Got it

geocities.com/appleide/game.rsrc.zip

The range thing still have problems when the viewport is moved to around centre of map, and the firing unit is in the cos quadrant when compared to the target.

Eg. 90-180 degrees truebearing from the target.

10-06-2006 03:24

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

I figured out that I already did calculate the angle when I was matching the ships facing to the target... Stuff the sin and cos stuff.

10-06-2006 17:43

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

> Stuff the sin and cos stuff.

????

Anyway if you're getting it to work then it's good...

10-06-2006 23:04

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

used this:

shipfacing[n]=Calculate Angle(sprite x(sprite[n])+ viewport x offset(2),sprite y(sprite[n])+viewport y offset(2) to (mouse x+2*viewport x offset (2)),(mouse y+2*viewport y offset (2)))

10-06-2006 23:29

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

glad it works =)

11-02-2006 11:02

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

Got a 2600 line project...

Got a 2600 line project...

...And all it does is read the files to obtain all the variables, and can resize arrays...

And I haven't written a single line of code for the actualy game yet!!

This is insane! I have been working on this for the past week... Finally completed :"Step1: Set up the variables."

Seriously... File Input/Output, arrays resizing, is really inefficient...

11-02-2006 11:07

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

btw... If you were wondering, I am rewriting the game because I had forgotten by "types" of units... I only had "single units"... If you get what I mean.

It is also now VERY structured code... for a 2600 line project that can only read some files, resize some arrays and print out some values.... ><

11-04-2006 21:54

Posted by:
Ledorax

Location:
Sweden

Click Here to Email Ledorax   Find more posts by Ledorax

That is really cool.

However, the spaceship doesn't always follow orders. Sometimes when I click somewhere it ignores me. Also, if I click somewhere and then click somewhere else the ship will not go there until it's traveled to where I clicked first. That can be really frustrating, especially if you're in the middle of a big battle and misclick, sending your fleet to it's doom!

Well done though!

11-11-2006 21:48

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

Yeah.. I am remaking it. :)

It sucks to see your game already made:
http://www.steampowered.com/v/index.php?area=game&;AppId=1690&
Especially when its nothing like what you imagined.

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.