copx schrieb:
> kalle.olli DeleteThis @saunalahti.fi schrieb:
>> Played ADOM ~100 hours and my dream is to make working RL game, i have
>> little to nothing codeing knowledge / skills so what is best program to
>> start with? 2D and ASCII is both fine to me.
>
> Please, NOT AGAIN!
> Now everyone will jump out of the woodwork just to recommend his
> favorite programming language! We have such threads every other month here!
>
> We really need an FAQ/Guide for this kind of question IMO. It should
> contain pointers to tutorials, solutions to common problems, example
> source code etc.. I can write a basic roguelikish program in BASIC that
> fits on a single page. In fact I will do this right now as a first
> contribution to the guide, which I will start at roguebasin soon after.
So here it is! This is were I started about three years ago.
The game is written in yabasic because I think the language is perfect
for a total newbie. You can download yabasic here:
http://yabasic.de/
Run my program and be impressed
After you have overcome your awe you can follow the links on the
yabasic site to one of the tutorials, and sooner than you might think
you will understand what the following stuff means (this is the
program code, just and copy and past it into notepad/your text editor
and save it as "rogue.yab" - you can execute yab files once yabasic
is installed)
#
# Norwegian Forest 1.0 by copx
#
# This is a simple roguelike demo program that allows
# the player the move an '@' around in a randomly
# generated forest
#
# To move use the number pad i.e. '4','6','8','2'
# If you want to terminate the program press 'x'
#
#
# setting up some variables (i.e. program data)
#
# the map
map_height = 20
map_width = 42
dim map(map_height, map_width)
number_of_tiles = 2
tree = 0
floor = 1
# the player position
player_x = 10
player_y = 10
#
# program initialization
# i.e. clearing the screen and generating a random map
#
clear screen
generate_random_map()
#
# the main game loop
# this loop repeats until the player terminates the program
#
do
render_screen()
player_command()
loop
#
# generate_random_map() sub program
#
# generates a random map - a nice snowy forest!
#
sub generate_random_map()
for y = 0 to map_height step 1
for x = 0 to map_width step 1
random_number = int(ran() * number_of_tiles)
if (random_number = 1) then
map(y, x) = tree
elsif (random_number = 0) then
map(y, x) = floor
endif
next x
next y
end sub
#
# render_screen() sub program
#
# renders the map and the player character
#
sub render_screen()
for y = 0 to map_height step 1
for x = 0 to map_width step 1
if (map(y, x) = tree) then
print color("green") at(x, y) "T";
elsif (map(y, x) = floor) then
print color("white") at(x, y) ".";
endif
next x
next y
print color("cyan") at(player_x, player_y) "@"
end sub
#
# player_command() sub program
#
# lets the player enter a command by pressing a key
# and executes the command
#
sub player_command()
pressed_key$ = inkey$
if (pressed_key$ = "2") then
player_y = player_y + 1
elsif (pressed_key$ = "8") then
player_y = player_y - 1
elsif (pressed_key$ = "6") then
player_x = player_x + 1
elseif (pressed_key$ = "4") then
player_x = player_x - 1
elseif (pressed_key$ = "x") then
exit
end if
end sub
>> Stay informed about: How to start making own Roguelike game?