Oh, ok, well even before you posted I fixed everything but the trees, I didnt think the player counted because it was a different thing (player.id instead of trees(x).id)
But anyways, if I did anything inneficiently, tell me.
rem |---------------------|
rem |---By Darkzombies----|
rem |--------KingX--------|
rem |---Pre-Alpha-0.2-----|
Rem |-Created-Oct-14-2011-|
rem |---------------------|
rem --------
rem | DATA |
rem --------
gosub types
scrwid = screen width()
scrheight = screen height()
loadimages()
player.movespeed = 2 `Change this if you need to.
player.x = scrwid-sprite width(player.id)
player.y = scrheight-sprite height(player.id)
sync on : sync rate 50
init()
#constant true 1
#constant false 0
global savegame$ = ""
global loadgame$ = ""
global savedir1 as string = "saves\save01.dat"
global savedir2 as string = "saves\save02.dat"
global savedir3 as string = "saves\save03.dat"
rem -------------
rem | MAIN LOOP |
rem -------------
do
PlayerInput()
text 550, 10, "Attack: " +str$(attack)
text 550, 25, "Defence: " +str$(defence)
`setuptrees()
sync
loop
flag = 1
wait 10000
flag = 0
rem ---------
rem | TYPES |
rem ---------
types:
type entity
x as integer
y as integer
anim as integer
directionx as integer
directiony as integer
att as integer `Inidividual attack/defence level
def as integer
movespeed as integer
id as integer
amount as integer
endtype
type terrain
x as integer
y as integer
direction as integer
anim as integer
id as integer
amount as integer
endtype
global player as entity
global dim knight(troops) as entity
global dim civilian(civs) as entity
global dim trees(10) as terrain
return
rem -------------
rem | FUNCTIONS |
rem -------------
function init() `Initialize everything!
rem |-----------|
rem |-DEBUGGING-|
rem |-----------|
player.directionx = 3
if player.directionx = 3 then mirror sprite player.id
player.directionx = 2 `Face right
sprite player.id, player.x+50, player.y, 1
player.x = player.x+player.movespeed
wait 0500
sprite player.id, screen width()/2-60, screen height()/2-10, 1
player.x = screen width()/2-60
player.y = screen height()/2-10
global troops = 5
global maxtroops = 5
global civs = 5
global maxcivs = 5
global houses = 2
global entroops = 6
global maxentroops = 6
global gold = 4000
global seiges = 0
global defences = 0
wait 0500
global attack = attack+troops+seiges
global defence = defence+troops+defences
endfunction
rem Ignore this for now!
function easy() `Just sets up the variables for easy difficulty.
global troops = 7
global maxtroops = 7
global civs = 7
global maxcivs = 7
global houses = 3
global entroops = 5
global maxentroops = 5
global gold = 5000
global seiges = 1
global defences = 1
wait 0500
global attack = attack+troops+seiges
global defence = defence+troops+defences
endfunction
function normal()
global troops = 5
global maxtroops = 5
global civs = 5
global maxcivs = 5
global houses = 2
global entroops = 6
global maxentroops = 6
global gold = 4000
global seiges = 0
global defences = 0
global attack = attack+troops+seiges
global defence = defence+troops+defences
endfunction
function hard()
global troops = 3
global maxtroops = 3
global civs = 3
global maxcivs = 3
global houses = 1
global entroops = 7
global maxentroops = 7
global gold = 3000
global seiges = 0
global defences = 0
wait 0500
global attack = attack+troops+seiges
global defence = defence+troops+defences
endfunction
function playerinput() `THESE WILL BE EXECUTED IN THE GAME LOOP, MAYBE A FUNCTION LOOP!
if upkey() = 1
player.directiony = 0 `Face up.
sprite player.id, player.x, player.y+player.movespeed, 1
player.y = player.y-player.movespeed
endif
if downkey() = 1
player.directiony = 1 `Face down.
sprite player.id, player.x, player.y-player.movespeed, 1
player.y = player.y+player.movespeed
endif
if rightkey() = 1
if player.directionx = 3 then mirror sprite player.id
player.directionx = 2 `Face right
sprite player.id, player.x+player.movespeed, player.y, 1
player.x = player.x+player.movespeed
endif
if leftkey() = 1
if flag = 1 then mirror sprite player.id
flag = 0
if player.directionx = 2 then mirror sprite player.id
player.directionx = 3 `Face left.
sprite player.id, player.x-player.movespeed, player.y, 1
player.x = player.x-player.movespeed
endif
endfunction player
function setuptrees()
for num = 1 to 10
tempy = 50 + 50
sprite trees(num).id, 600, tempy, 6
next num
endfunction
function loadimages()
for x = 1 to 10
trees(x).id = x
next x
player.id = 1
load image "media\knight.png", 1
load image "media\peasant.png", 2
load image "media\Bc.png", 3
load image "media\Bg.png", 4
load image "media\Bd.png", 5
load image "media\tree.png", 6
sprite player.id, 0, 0, 1
endfunction
Im fixing the trees atm.
EDIT: Ok, so theres only 1 tree...
rem |---------------------|
rem |---By Darkzombies----|
rem |--------KingX--------|
rem |---Pre-Alpha-0.2-----|
Rem |-Created-Oct-14-2011-|
rem |---------------------|
rem --------
rem | DATA |
rem --------
gosub types
scrwid = screen width()
scrheight = screen height()
loadimages()
player.movespeed = 2 `Change this if you need to.
player.x = scrwid-sprite width(player.id)
player.y = scrheight-sprite height(player.id)
sync on : sync rate 50
init()
#constant true 1
#constant false 0
global savegame$ = ""
global loadgame$ = ""
global savedir1 as string = "saves\save01.dat"
global savedir2 as string = "saves\save02.dat"
global savedir3 as string = "saves\save03.dat"
rem -------------
rem | MAIN LOOP |
rem -------------
do
PlayerInput()
text 550, 10, "Attack: " +str$(attack)
text 550, 25, "Defence: " +str$(defence)
setuptrees()
sync
loop
flag = 1
wait 10000
flag = 0
rem ---------
rem | TYPES |
rem ---------
types:
type entity
x as integer
y as integer
anim as integer
directionx as integer
directiony as integer
att as integer `Inidividual attack/defence level
def as integer
movespeed as integer
id as integer
amount as integer
endtype
type terrain
x as integer
y as integer
direction as integer
anim as integer
id as integer
amount as integer
endtype
global player as entity
global dim knight(troops) as entity
global dim civilian(civs) as entity
global dim trees(11) as terrain
return
rem -------------
rem | FUNCTIONS |
rem -------------
function init() `Initialize everything!
rem |-----------|
rem |-DEBUGGING-|
rem |-----------|
player.directionx = 3
if player.directionx = 3 then mirror sprite player.id
player.directionx = 2 `Face right
sprite player.id, player.x+50, player.y, 1
player.x = player.x+player.movespeed
wait 0500
sprite player.id, screen width()/2-60, screen height()/2-10, 1
player.x = screen width()/2-60
player.y = screen height()/2-10
rem It starts at normal, there will be a menu, but for now this works.
global troops = 5
global maxtroops = 5
global civs = 5
global maxcivs = 5
global houses = 2
global entroops = 6
global maxentroops = 6
global gold = 4000
global seiges = 0
global defences = 0
wait 0500
global attack = attack+troops+seiges
global defence = defence+troops+defences
endfunction
rem Ignore this for now!
function easy() `Just sets up the variables for easy difficulty.
global troops = 7
global maxtroops = 7
global civs = 7
global maxcivs = 7
global houses = 3
global entroops = 5
global maxentroops = 5
global gold = 5000
global seiges = 1
global defences = 1
wait 0500
global attack = attack+troops+seiges
global defence = defence+troops+defences
endfunction
function normal()
global troops = 5
global maxtroops = 5
global civs = 5
global maxcivs = 5
global houses = 2
global entroops = 6
global maxentroops = 6
global gold = 4000
global seiges = 0
global defences = 0
global attack = attack+troops+seiges
global defence = defence+troops+defences
endfunction
function hard()
global troops = 3
global maxtroops = 3
global civs = 3
global maxcivs = 3
global houses = 1
global entroops = 7
global maxentroops = 7
global gold = 3000
global seiges = 0
global defences = 0
wait 0500
global attack = attack+troops+seiges
global defence = defence+troops+defences
endfunction
function playerinput() `THESE WILL BE EXECUTED IN THE GAME LOOP, MAYBE A FUNCTION LOOP!
if upkey() = 1
player.directiony = 0 `Face up.
sprite player.id, player.x, player.y+player.movespeed, 1
player.y = player.y-player.movespeed
endif
if downkey() = 1
player.directiony = 1 `Face down.
sprite player.id, player.x, player.y-player.movespeed, 1
player.y = player.y+player.movespeed
endif
if rightkey() = 1
if player.directionx = 3 then mirror sprite player.id
player.directionx = 2 `Face right
sprite player.id, player.x+player.movespeed, player.y, 1
player.x = player.x+player.movespeed
endif
if leftkey() = 1
if flag = 1 then mirror sprite player.id
flag = 0
if player.directionx = 2 then mirror sprite player.id
player.directionx = 3 `Face left.
sprite player.id, player.x-player.movespeed, player.y, 1
player.x = player.x-player.movespeed
endif
endfunction player
function setuptrees()
for num = 2 to 11
tempy = 50 + 50
sprite trees(num).id, 600, tempy, 6
next num
endfunction
function loadimages()
for x = 2 to 11
trees(x).id = x
next x
player.id = 1
load image "media\knight.png", 1
load image "media\peasant.png", 2
load image "media\Bc.png", 3
load image "media\Bg.png", 4
load image "media\Bd.png", 5
load image "media\tree.png", 6
sprite player.id, 0, 0, 1
endfunction
Also, are there any good AI tutorials out there, I know how to do the actual AI(Randomize timer()/rnd(a #)) just not movement, (Except maybe like back and forth, or move with the player.)
Cause thats most likely what ill be doing next, unless someone wants to do some animations for me lol.
"Insert funny coding-related joke here"