Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / is there an Array Tutorial (used search)

Author
Message
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 21st Jun 2008 12:58
im making a game (text) where u have an army and need to get more land/alliences
basicly world domination through text.
and someone told me that (thanks again to him) i should use Arrays to save the data of each unit
so is there a tutorial about arrays somewere?
i want to make a spearmen for example which has say.. 10 attack and 15 defence.
and another unit which has say 15 attack and 10 defence.
how do i make the arrays for this and make the pc calculate the outcome.

Creators of Outscape
nackidno
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Där solen aldrig skiner
Posted: 21st Jun 2008 14:20
I found this one, though I haven't taken the time to look it throught. Maybe something that can help you?

http://forum.thegamecreators.com/?m=forum_view&t=84908&b=7

- Elias, Damezean, Nackidno, Wonderboy

AntocGames - http://antocgames.se.nu/
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 21st Jun 2008 14:46
ill read it even if it does or doesnt

Creators of Outscape
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 21st Jun 2008 16:04
can anyone give me a pseubo (whatever) code for a unit? of defense and attack
i dont care what it says aslong as u tell me what each number stands for

Creators of Outscape
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 22nd Jun 2008 17:53
still dont get it at all =S
how do i do it that a unit has a x amount of attack/defence
i dont know what im talking about because someone told me arrays were what i wanted i have no clue what im ment to do but heres what i want:
in a game (text) you have an army and u attack another..
the units have certain stats that somehow need to be saved or somthing, and the pc needs to calculate the outcome

Creators of Outscape
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 22nd Jun 2008 18:24 Edited at: 22nd Jun 2008 18:28
so if i wanted to make a spearmen i do this????




Creators of Outscape
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 22nd Jun 2008 20:13
OHHHHHH!!!!!!!!!!!!
ok one last thing:
#CONSTANT UNIT_SPEARMAN 1 <- are those varibles and that a varible number
#CONSTANT UNIT_SOMEENEMY 2

TYPE Unit
class AS INTEGER <- say if i wanted more stats i put them there 'as INTEGER'?
attack AS INTEGER
defence AS INTEGER
ENDTYPE

DIM units() AS Unit

` create a spearman
ARRAY INSERT AT TOP units(0)
units(0).class = UNIT_SPEARMAN
units(0).attack = 10
units(0).defence = 15

` create an enemy
ARRAY INSERT AT TOP units(0)
units(0).class = UNIT_SOMEENEMY
units(0).attack = 20
units(0).defence = 5

ok i understand all that now i think, how do i get the pc to calcuatle the outcome?
like who will win
say 1000 spears attacking 1000 'UNIT_SOMEENEMY'
how do i make the pc calculate it?

Creators of Outscape
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 22nd Jun 2008 21:52
IT WORKS (would of posted earlier but i was getting it to work in my game)
I LOVE YOU YOUR AMAZING I LOVE YOU!!!!!!!!!!!!!
CAN I REPAY U SOMEHOW =)
U HELPED ME SOOOO MUCH!

Creators of Outscape
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 22nd Jun 2008 22:10
before u go if i want the enemy to have a set amount of troops do i:
change it to
FOR x = 1 TO 500 <-do i make that a number
ARRAY INSERT AT TOP units(0)
units(0).class = UNIT_SOMEENEMY
units(0).attack = 10
units(0).defence = 5
NEXT x

Creators of Outscape
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 22nd Jun 2008 22:23
well...
it stops working


Creators of Outscape
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 22nd Jun 2008 22:26
oh i had to do this


Creators of Outscape
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 22nd Jun 2008 22:33
OH!!!
ill try that
IT WORKS thankyou!!!!

Creators of Outscape
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 23rd Jun 2008 00:38
sorry if im annoying you
how do i change the fighting system?
eg:
it seems if you have a higher attack then the opponents defense
you will win
no matter on your unit amounts...
can this be fixed that the total defense/attack of ur army is all added up and calculated with?
also how do i add new things like hit points?

Creators of Outscape
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 23rd Jun 2008 18:28
yes but i dont know what part to change

Creators of Outscape
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 23rd Jun 2008 19:14
i tried making my own but i need it to say how many troops are lost and so i can make it decrease the players troops by an x amount.


Creators of Outscape
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 23rd Jun 2008 19:15
thats a symbol game thing i made and it prints your troops, your total attack and ur total defence

Creators of Outscape
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 23rd Jun 2008 19:53
i think ive figured it out
if the enemys defence is a certain % of your attack u loose that % of troops
like if 10 of ur guys attack 10 enemys
and u have 100 attack and they have 50 defence
u will loose 5 troops
and if you have 100 attack and they have 110 defence they % will be over 100% so u loose all ur troops

i just gota figure out how to use %s

Creators of Outscape
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 23rd Jun 2008 20:14
YES! EURKEA
if you have 14000 offense and they have 5000 defence then you do this
5000/14000*100

Creators of Outscape
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 23rd Jun 2008 20:38
5000/14000*100 gives the %
troopnumber*0.%

Creators of Outscape
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 23rd Jun 2008 20:50
is this programming software stupid or am i getting it wrong?

5000/14000*100
is 35.71428571
but the software thinks its 0??????????????
and also to find to amount of troops that need to go i need to:
(troop amount)2000*0.3571428571
0. is for the % its how it is calculated on a calculator
and then after the 0. is the % you have calculated
the number is 714.2857142
but the software says theres an error in doing:
0.percentage2#
and percentage2# is the calculations to find the %

Creators of Outscape
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 23rd Jun 2008 21:00 Edited at: 23rd Jun 2008 21:04
ok thankyou because of your helping hand:
ill put u in all my games credits and if possible give u some of those game store points if i ever gets some and u can trade them =D
i love you!!!
wait b4 you go god
i still have 1 error

'variable `0` name is not valid at line 3

Creators of Outscape
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 23rd Jun 2008 21:10 Edited at: 23rd Jun 2008 21:43
FIXED IT
i change the sum it is a longer calculation but it gets same answer
how one last question
how do i make the number round up or down

i cant loose 700.45 men
i cant have a .45 of a man can i?
dont answer that actually =)

but how do i round this up to 701
(not rowning down because you need at least 701 people to loose 700.45



i just want it to delete all decimals and increase the value by 1

Creators of Outscape
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 23rd Jun 2008 22:55 Edited at: 23rd Jun 2008 23:08
btw if anyone wants to use my engine i dont mind
all you have to do is change the variables at the top and the engine works the rest out!
oh btw if u press a key it will give you the results if you were defending and press again and it will go back to attacking


Creators of Outscape

Login to post a reply

Server time is: 2024-09-27 16:32:37
Your offset time is: 2024-09-27 16:32:37