News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

An RTS example. Screenshot only. not done yet

Started by LemonWizard, December 04, 2011, 08:39:21 AM

Previous topic - Next topic

LemonWizard

This is the screenshot.
ENJOY :P
Btw yes it is coded I just dont want to give out the code yet (believe me.. it's messy )

The game is going to be a time based rts game.
My art sucks.
ANY WILLING ARTISTS :D

kevin


LemonWizard

Okay. I didn't want to do this but I thought.. if anything goes wrong and I dont have a post of this I'd be annoyed plus this is a good way to track my progress.
I just got so bored of my other projects weren't going anywhere.
Here's the code.
do keep in mind it's not polished and alot of things will be changed.


SETFPS 60
newgame=true
world=loadnewimage("world.bmp")
enemytown=loadnewimage("Town_Icon.bmp")
focus=loadnewimage("You_Focus_Icon.bmp")
menu=loadnewfximage("menu.bmp")
yousiege=loadnewfximage("Town_You_Siege.bmp")
yourtown=loadnewfximage("Town_Icon_Captured.bmp")
imagemaskcolour enemytown, rgb(255, 255, 255)
imagemaskcolour focus, rgb(255, 255, 255)
imagemaskcolour menu, rgb(255, 255, 255)
imagemaskcolour yousiege, rgb(255, 255, 255)
imagemaskcolour yourtown, rgb(255, 255, 255)



if newgame=true
day=1
time=12

dim enemylocations(12, 2)
dim towntimers(12, 2) ;12 towns, a timer for the days and/or hours
dim town_tasks(12);
dim town_owners(12);

for temp=1 to 12
enemylocations(temp, 1)=rndrange(50, getscreenwidth()-100 )
enemylocations(temp, 2)=rndrange(50, getscreenheight()-100 )
town_owners(temp)=2 ;the cpu owns all towns to start
next temp



endif
time_timer=timer()+120000


;the main loop
;simple text based rts just for shits n shit
do

drawworld(world)
draw_locations(yousiege, yourtown, enemytown)
print "The current day is " +str$(day)
seconds=timer()/2000
real_seconds=60- ( (time_timer/2000)-seconds)
print "The current time is "+str$(time)+":"+str$( real_seconds)

if timer()>time_timer
time_timer=timer()+120000
time, day=hour_passed(time, day)
endif

draw_minute_bar(real_seconds)
if leftmousebutton()
player_focus=check_focus(player_focus) ;; check the focus, only executes main code if mouse was clicked
endif

if leftmousebutton()
item=checkmenu()
if item>0
set_town_task(player_focus, 1, 0, 1)
endif
endif



for temp=1 to 12
status=check_town_task(temp)
if status=3
town_owners(temp)=1 ;player
set_town_task(temp, 0, 0, 0)
endif
next temp



drawmenu(menu)
drawfocus(focus, player_focus)






sync
cls rgb(0,0,0)



loop

function hour_passed(time,  day)
x=time
y=day
x=x+1

;;this block of code checks the towns..
for temp=1 to 12
d=towntimers(temp, 1) ;the day of this town timer
h=towntimers(temp, 2) ;the hour of this town timer

;check the hours first
;since only the hour changed

if h>0 ;if there even is any time on this town left
h=h-1 ;take 1 away
if h=<0 ;check to see if a day has passed on this town
d=d-1
endif
endif


;now we check if there's even any days left
if d>0
h=12
endif

if d<0 ;if there are no days left at all...
town_tasks(temp)=3 ; 3 means the task was being done but it's over now and the task was conquered
endif



next temp


if x>12
x=0
y=y+1
endif
time=x
day=y

endfunction time, day

function draw_minute_bar(real_seconds)

x=200
y=15

for temp=1 to real_seconds*2



ink rgb(255, 2*temp, 0)
box 200+temp, y, 200+temp+1, y+10
next temp

ink rgb(255, 255, 255)
box x, y, x+60*2, y+10, 0

endfunction

function drawworld(world)

drawimage world, 0, 0, 0


endfunction

function draw_locations(yousiege, yourtown, enemytown)

for temp=1 to 12
x=enemylocations(temp, 1)
y=enemylocations(temp, 2)
owner=town_owners(temp)
if owner=1
drawimage yourtown, x, y, 1
endif
if owner=2
drawimage enemytown, x, y, 1
endif


status=check_town_task(temp)
if status=1
drawimage yousiege, x, y, 1
endif




next temp


endfunction

function check_focus(player_focus)


for temp=1 to 12
x=enemylocations(temp, 1)
y=enemylocations(temp, 2)
if mouseinbox(x, y, x+71, y+86)
player_focus=temp
exitfor
endif

next temp

endfunction player_focus

function drawfocus(focus, player_focus)

x=enemylocations(player_focus, 1)
y=enemylocations(player_focus, 2)
drawimage focus, x, y, 1



endfunction

function drawmenu(menu)

drawimage menu, 700, 400, 1

endfunction

function checkmenu()
x=700
y=400
if mouseinbox(0+x, 0+y, 96+x, 38+y)
item=1
endif




endfunction item

function set_town_timer(town_number, days,hours) ;;this is time in hours or days HH, DD

towntimers(town_number, 1)=days
towntimers(town_number, 2)=hours

endfunction

function set_town_task(town_number, task, d, h)

town_tasks(town_number)=task
set_town_timer(town_number, d, h)


endfunction

function check_town_task(town_number)

number=town_tasks(town_number)
if number=3
task_status=3
endif

if number=1
task_status=1
endif



endfunction task_status



my favourite thing about this is my  use of recursion to abstract some of the time functions into other time functions
The set_task. mainly.
I'm tired. Been at this all night hehe. time for a nap.
Enjoy. A demo will be posted later if I feel like.. I dunno. This doesn't belong in the show case so it'll be posted here.
Just something to pass the time. really excited about this though.

BlinkOk


LemonWizard

nah it's not that big. Lol it's only 800*600  ::)  ;)

not really sure where to go with this now there's so much I could do.
I just wish I had better graphics or an artist