Battleship Python Code Edited

Closed

Description

Need to complete the following python shell code:

import pygame

import random

# RESOURCES

def drawBoards(screen, board1, board2):

[url removed, login to view](screen, 40, 80, 25)

[url removed, login to view](screen, 350, 80, 25)

[url removed, login to view]()

def convertToBoard(pos):

x = int((pos[0] - 350) / 25)

y = int((pos[1] - 80) / 25)

return (x, y)

class Board:

def __init__(self):

[url removed, login to view] = [[0 * 10] * 10 for x in range(10)];

def drawSelf(self, screen, x, y, tileSize):

for r in range(len([url removed, login to view])):

for c in range(len([url removed, login to view][r])):

if [url removed, login to view][r][c] == 0: # blank water = blue

drawColor = (0, 0, 255)

elif [url removed, login to view][r][c] == 1: # unhit ship = light blue

drawColor = (150, 150, 255)

elif [url removed, login to view][r][c] == 2: # miss = yellow

drawColor = (255, 255, 0)

elif [url removed, login to view][r][c] == 3: # hit ship = red

drawColor = (255, 0, 0)

[url removed, login to view](screen, drawColor, [url removed, login to view](x + c * tileSize, y + r * tileSize, tileSize, tileSize))

for r in range(len([url removed, login to view])):

[url removed, login to view](screen, (0, 0, 0), (x + r * tileSize, y), (x + r * tileSize, y + len([url removed, login to view]) * tileSize))

[url removed, login to view](screen, (0, 0, 0), (x, y + r * tileSize), (x + len([url removed, login to view]) * tileSize, y + r * tileSize))

def setValue(self, x, y, value):

[url removed, login to view][y][x] = value

def getValue(self, x, y):

return [url removed, login to view][y][x]

def enemyAttack(player):

# DO STUFF HERE

# /DO STUFF HERE

return False

def playerAttack(enemy, seenEnemy, x, y):

# DO STUFF HERE

# /DO STUFF HERE

return False

def placeShip(board, shipSize):

# DO STUFF HERE

# /DO STUFF HERE

pass

# /RESOURCES

screen = pygame.display.set_mode((640, 480))

playersTurn = True

# TODO: set up player, enemy, and seenEnemy boards

# DO STUFF HERE

# place ships

# /DO STUFF HERE

while True:

evt = [url removed, login to view]()

if [url removed, login to view] == [url removed, login to view]:

break

if playersTurn and [url removed, login to view] == [url removed, login to view]:

# process mouse actions

coord = convertToBoard([url removed, login to view])

x = coord[0]

y = coord[1]

# TODO: process human input, fire at point (x, y)

# DO STUFF HERE

# /DO STUFF HERE

# process enemy attack

if not playersTurn:

if enemyAttack(player):

enemyHits += 1

playersTurn = True

# TODO: call drawBoards with appropriate input

# DO STUFF HERE

# /DO STUFF HERE

# after victory, wait for X button

while True and (playerHits == 17 or enemyHits == 17):

evt = [url removed, login to view]()

if [url removed, login to view] == [url removed, login to view]:

break

[url removed, login to view]()

Skills: Python

See more: battleship python, python battleship, battleship python code, battleship code python, python battleship code, python code battleship, battleship code, range resources, python button, python data, len, random pass, pygame, python display data, python stuff, screen flip, flip screen, battleship pygame, code event, edited, code pos, python class, call python, enemy, class battleship

Project ID: #4467000

8 freelancers are bidding on average $348 for this job

tlyx

Could you please send the code as Python file?

$385 USD in 6 days
(22 Reviews)
4.6
ddhnyh1

Hi. Please check my pm.

$367 USD in 6 days
(2 Reviews)
3.0
tkordic

Greetings, I am developer with 3+ years of experience with python, looking forward to work with you on implementation of battleship game.

$275 USD in 5 days
(1 Review)
2.1
elmashoya

hello, i am a professional developer, i have checked ur requirements and consider it done with quality, my freelancer username is my skype and gmail, waiting to discuss with u

$262 USD in 4 days
(2 Reviews)
0.6
Qiantangren

I hope I could help you to solve this problem. The work I use python development, so the problem is that I can quickly help you solve.

$550 USD in 3 days
(0 Reviews)
0.0
MostafaSM

Please check your PM

$275 USD in 2 days
(0 Reviews)
0.0
pmwheatley

Dear Sir, Having read your project, and the accompanying PDF I believe this project could be completed in approximately 2-3 days. I am offering fully commented code and inclusion of the 'extra-credit' assignment (i.e. More

$275 USD in 3 days
(0 Reviews)
0.0
solomonhume

I am a skilled python programmer and I have made games with pygame before. Your project is a piece of cake for me. Money back guarantee if not satisfied, for whatever reason.

$275 USD in 3 days
(0 Reviews)
0.0
pedjaa

I can do it

$385 USD in 5 days
(0 Reviews)
0.0