I am trying to make a simple "shooter" game. It's basically an imagemap (where you click on the target and hit it), but because using a mouse to do that is super easy and boring, I wanted to use keyboard inputs. The "gun", in this case, is a catapult, so I wanted something that felt more clunky and difficult to use.
So far, I'm happy with the controls I have set up. The image I'm moving about is a crosshair. However, I'm stuck on how, when the target is hit, to register it...
Here's my catapult screen so far (note: I am using Elmiwisa's code from this thread viewtopic.php?f=8&t=23163#top ):
Code: Select all
init -2 python:
class Coordinate:#this one is to manage the CATAPULT's location on the screen
def __init__(self,x,y,xmin,ymin,xmax,ymax):
self.x,self.y,self.xmin,self.ymin,self.xmax,self.ymax=x,y,xmin,ymin,xmax,ymax
self.xoffset,self.yoffset=0,0
return
def transform(self,d,show_time,animate_time):
self.x+=self.xoffset
self.y+=self.yoffset
self.xoffset,self.yoffset=0,0
if self.x<self.xmin:
self.x=self.xmin
if self.y<self.ymin:
self.y=self.ymin
if self.x>self.xmax:
self.x=self.xmax
if self.y>self.ymax:
self.y=self.ymax
d.pos=(self.x,self.y)
return 0
catapult_coordinate=Coordinate(0.5,0.5,0.05,0.05,0.95,0.95)
screen catapult_target:
add "catapult loc" anchor (0.5,0.5) at Transform(function=catapult_coordinate.transform) # the target image
key "focus_left" action SetField(catapult_coordinate,"xoffset",-0.05) activate_sound "sounds/shuffle.ogg"
key "focus_right" action SetField(catapult_coordinate,"xoffset",+0.05) activate_sound "sounds/shuffle.ogg"
key "focus_up" action SetField(catapult_coordinate,"yoffset",-0.05) activate_sound "sounds/shuffle.ogg"
key "focus_down" action SetField(catapult_coordinate,"yoffset",+0.05) activate_sound "sounds/shuffle.ogg"
key "dismiss" action Return()Code: Select all
call screen catapult_target
if catapult_coordinate(0.1, 0.2, 0.1, 0.2):
#if catapult_coordinate.xpos < 0.2:
# if catapult_coordinate.ypos > 0.1:
# if catapult_coordinate.ypos < 0.2:
with vpunch
"You Hit. "
$ shots_fired += 1
$ targets_hit += 1
if shots_fired >= 3:
pass
else:
call attack # goes back to top
with vpunch
"You Missed. "
$ shots_fired += 1
if shots_fired >= 3:
pass
else:
call attackCode: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 5144, in script call
call second_memory
File "game/memories.rpy", line 7898, in script
if catapult_coordinate(0.1, 0.2, 0.1, 0.2):
File "game/memories.rpy", line 7898, in <module>
if catapult_coordinate(0.1, 0.2, 0.1, 0.2):
TypeError: 'Coordinate' object is not callable
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/script.rpy", line 5144, in script call
call second_memory
File "game/memories.rpy", line 7898, in script
if catapult_coordinate(0.1, 0.2, 0.1, 0.2):
File "/Applications/renpy-6.99.11-sdk/renpy/ast.py", line 1762, in execute
if renpy.python.py_eval(condition):
File "/Applications/renpy-6.99.11-sdk/renpy/python.py", line 1944, in py_eval
return py_eval_bytecode(code, globals, locals)
File "/Applications/renpy-6.99.11-sdk/renpy/python.py", line 1937, in py_eval_bytecode
return eval(bytecode, globals, locals)
File "game/memories.rpy", line 7898, in <module>
if catapult_coordinate(0.1, 0.2, 0.1, 0.2):
TypeError: 'Coordinate' object is not callable