Re: creating a game ... ? (help!)

new topic     » goto parent     » topic index » view thread      » older message » newer message

----- Original Message ----- 
From: "Lobelia Overhill" <guest at RapidEuphoria.com>
To: <EUforum at topica.com>
Sent: Saturday, September 04, 2004 6:58 AM
Subject: creating a game ... ? (help!)


>
>
> posted by: Lobelia Overhill <lobeliaoverhill at yahoo.com>
>
>
> Argh a newbie ...
>
> Myself an a friend were reminiscing about our traumatic childhoods, and I
> recall that during those dark days, I used to amuse myself by playing a
> game using pen and paper (remember those things?!?) which involved
> running a [horse] riding school initially, but evolved into running a
> showjumping yard (barn if you're an American), where I invented
> competitions and used a dice to decide who won.
>
> I'd like to build on that and create a similar game for my computer (for
> myself), and I'm wondering if Euphoria would be a good program to use?
> I would like to have it running from my hard drive or a CD ROM ...
>

Lobelia,

I've read your very detailed program outline (nicely done!), & I understand
that you don't yet know how to program in Euphoria, and people have
suggested that you start with a text based game.  And you've been given some
excellent advice (read & study the reference manual, look at all the demo
programs, start small, etc).

Here's my suggestion, & some code to show you what I mean:

1.  re-do your outline so it is composed clearly of small "blocks" of things
to do, one leading directly to the next, like "show the program name",
"select a lot size", "name the lot", etc.
2.   then make a "framework" within which to place all the blocks;
3.   then write code to accomplish the intention of each block (in
"procedures");
4.   then place all the procedures in the "framework".

first a small example, then some actual code:

small example:
procedure ShowTheProgramName()
  --code to show the program name on the screen.
end procedure

procedure SelectSomeLand()
 -- code to allow game player to select from different sizes of lots
end procedure

procedure NameTheRanch()
  -- code to allow player to name their ranch
end procedure

-- program execution actually begins here:
ShowTheProgramName()
SelectSomeLand()
NameTheRanch()

-- end of program



now for some actual code, which runs:
-- horse breeding game

-- everything preceded by double dashes are COMMENTS, which are
-- not acted upon as program commands.


--  the following two lines "add in" some useful/necessary routines
--  from some "library" files, as named.
include get.e
include graphics.e
----------------------------------------------

-- the following are some variables used in the program;
-- you can change them here to easily make them different in your program:
sequence PlayerName, Lots  -- lots is a sequence of various acreages
sequence RanchName
integer quit, aChoice, funds, dummy, CostPerAcre

quit = 0
funds = 500000
Lots = {20, 50, 100, 200, 500, 1000, 2000, 5000}  -- some sizes of lots
CostPerAcre = 100

-- aChoice can be used throughout the program for various menu selections

----------------------------------------------

-- PROCEDURES USED IN PROGRAM:

procedure GameId()
  clear_screen()
  puts(1, "\n\n\n              A   H O R S E    R A N C H\n\n\n")
end procedure

procedure PurchaseRanch()
  integer LandCost
    LandCost = 0
    aChoice = 0

    puts(1, PlayerName & ", you have $500,000 with which to build a horse
ranch.\n")
    puts(1, "You will need to purchase land, horses, and various other
items,\n" &
             " so budget your funds wisely!\n\n\n" )

    puts(1,  "  PURCHASE LAND FOR YOUR RANCH from the following:\n\n")
    -- display 8 possible choices for land purchase:
    for n = 1 to 8 do
        puts(1, sprint(n) & ".  " & sprint(Lots[n]) & "acres for $" &
                sprint(Lots[n] * CostPerAcre) & "\n")
    end for

    aChoice= prompt_number("Enter a number choice, 0 to quit\n", {0,8})
    if aChoice = 0 then
       quit = 1
       return
    else
       LandCost = Lots[aChoice] * CostPerAcre
    end if

    funds = funds - LandCost
    puts(1, "You have $" & sprint(funds) & " left.\n")

    puts(1, "press any key to continue")
    dummy = wait_key()


end procedure


procedure NameRanch()
  if quit then
     return
  end if
   GameId()
   RanchName = prompt_string("Enter a name for your ranch, or q to quit:\n")
   if equal(RanchName, "q") then
      quit = 1
      return
   end if
   puts(1, "Your ranch is now named " & RanchName & "\n")
   puts(1, "\n\n" & PlayerName & ", you have $" & sprint(funds) & "
left.\n")
    puts(1, "press any key to continue")
    dummy = wait_key()
end procedure

-- PLACE OTHER PROCEDURES HERE, THEN CALL THEM AS NEEDED, in PlayGame()

------------------------------------------------------------

-- main game procedure:
procedure PlayGame()

  GameId()  -- does the procedure above named "GameId"
  PurchaseRanch()  -- does the procedure above named "PurchaseRanch"
  NameRanch()  -- does the procedure above named "NameRanch"

--  now provide procedures for following, & call them here:
  -- develop ranch
  -- buy horse
  -- select living space for horse

--  etc, etc, etc.



  if quit then
     return
  end if

end procedure



-- program entry/exit:
  GameId()  -- identifies the program to the user on entry
  PlayerName = prompt_string("Enter your name, or q to quit:\n")
  if equal(PlayerName,"q") then
     -- will exit program by falling through to the last lines below
  else
     PlayGame()
  end if


  -- these last lines clears the screen on exit:
  if graphics_mode(-1) then
  end if


new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu