Jump to content

  • Log In with Google      Sign In   
  • Create Account


How to create games using Python


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 louie999   Members   -  Reputation: 127

Like
0Likes
Like

Posted 29 January 2014 - 10:47 AM

I'm creating a game,and I'm new to these Programming stuff.I would like to create an good(or hard)Ai for my game How do I create an Ai that can do these things:

 

1.When it sees an enemy it will shoot it.

2.When getting shot it will take cover or run away/retreat.

3.Will NOT shoot allies.(If on Team games)

4.When an Ally is near and getting shot the Ai teammate will help.

5.Can camp and/or hide from the enemy or ambush an enemy.

6.Will protect and stay in the base if there are no one guarding it(On Kill the Base mode)

7.Will capture the enemy flag and bring it to back to base.(On capture the flag mode)

 

I'm planning on creating many game modes,like:

Deathmatch - No teams just kill anyone you see.

Team Deathmatch - Up to 4 teams.

Defend the Base - Defend the base against waves/hordes of zombies.

Kill the Base - Kill/Destroy the enemy base and not letting your get destroyed.

Capture the Flag - Capture the enemies Flag and bring it back to your base.

Elimination - Each player has there set of lives if it gets to 0 you lose,Team or No teams

 



Sponsor:

#2 exOfde   Members   -  Reputation: 807

Like
5Likes
Like

Posted 29 January 2014 - 11:37 AM

do you know the language already? 

then I would suggest to use pygame (http://www.pygame.org) as base for

your game. IF you not know the language yet, I say go a step back.

Start with some easier topics. Don't try to do something where you lack

to much of programming experience. Start slow and take it step for step.

 

  • Learn your language
    • train Text Input / Output on the console
    • train File Input/ Output
    • program an calculator first
    • learn about algorhythm
    • wrote a programm which try to organise simple data( e.g. table numbers and names )
  • Learn the API of PyGame
    • learn to initialize a Window
    • try to draw a picture
    • try to move a picture
    • try to clip a picture
    • try to play sound
    • try to handle input
    • try to move a picture with your input
    • try to move a picture with your input and check if it hit something.
    • try to move a picture with your input and check if it hit something and play a sound.
    • try to write something on the screen
    • try to read some user input over the screen and print what the user wrote on the screen

If you have done all this you can take the next step and write and game like tic tac to or an sidescroller, etc

but important is you go step by stepstep by stepstep by step into the topic. Otherwise you will get frustrated and stop.

The clue is if you go small steps you will see progress and progress ends often in success. both progress and success let you

feel very good. belive me, perhaps that takes some time, but that is an relative save way to go. of course is my list above only

a example/suggestion( my example only includes graphical stuff ;) ). which way you will go is up to you.

 

If you want learn something about AI's use this site there is really a lot stuff you could use: http://aima.cs.berkeley.edu/index.html


Edited by exOfde, 29 January 2014 - 11:52 AM.


#3 BitMaster   Crossbones+   -  Reputation: 3653

Like
3Likes
Like

Posted 29 January 2014 - 11:39 AM

Considering you just started, none of those are questions you should be asking. They cannot be answered in a (to you) helpful way either.

 

Start with something small. Like Guess-a-number. The program creates a random number and asks the user to guess it. The program tells the user "right" or "wrong" after each guess, the program ends when the user guessed right.

If you have never programmed anything before, this is a very significant challenge.



#4 Shippou   Members   -  Reputation: 1336

Like
2Likes
Like

Posted 29 January 2014 - 11:46 AM

I would suggest reading this free beginners book to programming, that also teaches basic game prigramming [LINK]  .

Here is another free, but bit more advanced book to read on Python game creation [LINK] .

 

 If you would like to learn the basics of programming and Python, this free book is great [LINK] !


 Reactions To Technologies:
1. Anything that is in the world when you’re born is normal and ordinary and is just a natural part of the way the world works.
2. Anything that's invented between when you’re fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it.
3. Anything invented after you're thirty-five is against the natural order of things.

- Douglas Adams 2002


 


#5 Vidar son of Odin   Members   -  Reputation: 1320

Like
1Likes
Like

Posted 29 January 2014 - 01:43 PM

do you know the language already? 

then I would suggest to use pygame (http://www.pygame.org) as base for

your game. IF you not know the language yet, I say go a step back.

Start with some easier topics. Don't try to do something where you lack

to much of programming experience. Start slow and take it step for step.

 

  • Learn your language
    • train Text Input / Output on the console
    • train File Input/ Output
    • program an calculator first
    • learn about algorhythm
    • wrote a programm which try to organise simple data( e.g. table numbers and names )
  • Learn the API of PyGame
    • learn to initialize a Window
    • try to draw a picture
    • try to move a picture
    • try to clip a picture
    • try to play sound
    • try to handle input
    • try to move a picture with your input
    • try to move a picture with your input and check if it hit something.
    • try to move a picture with your input and check if it hit something and play a sound.
    • try to write something on the screen
    • try to read some user input over the screen and print what the user wrote on the screen

If you have done all this you can take the next step and write and game like tic tac to or an sidescroller, etc

but important is you go step by stepstep by stepstep by step into the topic. Otherwise you will get frustrated and stop.

The clue is if you go small steps you will see progress and progress ends often in success. both progress and success let you

feel very good. belive me, perhaps that takes some time, but that is an relative save way to go. of course is my list above only

a example/suggestion( my example only includes graphical stuff ;) ). which way you will go is up to you.

 

If you want learn something about AI's use this site there is really a lot stuff you could use: http://aima.cs.berkeley.edu/index.html

 

 

Considering you just started, none of those are questions you should be asking. They cannot be answered in a (to you) helpful way either.

 

Start with something small. Like Guess-a-number. The program creates a random number and asks the user to guess it. The program tells the user "right" or "wrong" after each guess, the program ends when the user guessed right.

If you have never programmed anything before, this is a very significant challenge.

 

 

I would suggest reading this free beginners book to programming, that also teaches basic game prigramming [LINK]  .

Here is another free, but bit more advanced book to read on Python game creation [LINK] .

 

 If you would like to learn the basics of programming and Python, this free book is great [LINK] !

HAHAlaugh.png  You people just ruined this guy dreams.. Louie..yea. You must start small. If this will be your first game, learn firstly how to programm and how is structured a game. Don't jump directly to AI! 


Check out my portfolio : https://bratie.wordpress.com

"Don't gain the world and lose your soul. Wisdom is better than silver or gold." - Bob Marley

 


#6 pyirrlicht   Members   -  Reputation: 618

Like
3Likes
Like

Posted 30 January 2014 - 01:25 AM

1.When it sees an enemy it will shoot it.

class Coord:
 def __init__(self, x = 0, y = 0, have_enemy = False):
  self.x = x; self.y = y; self.have_enemy = have_enemy

# global array Coords, you must set this as all your game cells and change later in game loop
Coords = (Coord(0, 0, False), Coord(0,1,False), Coord(1,1, True))

def shoot(coord):
 pass # change to your code

def collision_with_enemy():
 for coord_item in Coords:
  if coord_item.have_enemy:
   shoot(coord_item)


#7 louie999   Members   -  Reputation: 127

Like
0Likes
Like

Posted 30 January 2014 - 03:54 AM

 

1.When it sees an enemy it will shoot it.

class Coord:
 def __init__(self, x = 0, y = 0, have_enemy = False):
  self.x = x; self.y = y; self.have_enemy = have_enemy

# global array Coords, you must set this as all your game cells and change later in game loop
Coords = (Coord(0, 0, False), Coord(0,1,False), Coord(1,1, True))

def shoot(coord):
 pass # change to your code

def collision_with_enemy():
 for coord_item in Coords:
  if coord_item.have_enemy:
   shoot(coord_item)

 I dont understand this sad.png ohmy.png

its so complicated(for me)



#8 Vidar son of Odin   Members   -  Reputation: 1320

Like
2Likes
Like

Posted 30 January 2014 - 05:03 AM

 

 

1.When it sees an enemy it will shoot it.

class Coord:
 def __init__(self, x = 0, y = 0, have_enemy = False):
  self.x = x; self.y = y; self.have_enemy = have_enemy

# global array Coords, you must set this as all your game cells and change later in game loop
Coords = (Coord(0, 0, False), Coord(0,1,False), Coord(1,1, True))

def shoot(coord):
 pass # change to your code

def collision_with_enemy():
 for coord_item in Coords:
  if coord_item.have_enemy:
   shoot(coord_item)

 I dont understand this sad.png ohmy.png

its so complicated(for me)

 

Why you jump already to AI? Make a simple game for start. My first game was a tic tac toe clone (without AI) and my first game including artificial intelligence was PONG.

Check my profile to see them.

And here is a book about making games in Python and Pygame. Read It!

http://inventwithpython.com/makinggames.pdf

 


Edited by Bratie Fanut, 30 January 2014 - 05:10 AM.

Check out my portfolio : https://bratie.wordpress.com

"Don't gain the world and lose your soul. Wisdom is better than silver or gold." - Bob Marley

 


#9 pyirrlicht   Members   -  Reputation: 618

Like
2Likes
Like

Posted 31 January 2014 - 03:37 AM

 I dont understand this

you can learn draw cells example, mainly "live_grid_2d" class - perhaps it helps to understand how to divide the screen into areas for further work with them






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS