diff --git a/main.py b/main.py index dcdaf4e..c3f314e 100644 --- a/main.py +++ b/main.py @@ -153,11 +153,13 @@ def resetFishingState(app): # is resolved/dismissed. app.skillCheckAngle = 0 #measured in degrees app.skillCheckSpeed = 1 - app.skillCheckBars = [] + app.skillCheckBars = [] # list of tuples of form (position, length) app.skillCheckFailed = False app.hookedFish = None app.fishingTimer = 0 + + app.scene = "idle" pass @@ -221,7 +223,8 @@ def startSkillCheck(app, creature): #speed is set, bars are set, scene is good, should be fine? def beginFishing(app): - pass + app.fishingTimer = random.random() * app.stepsPerSecond * 25 + 5 # completely random between 5 and 30 + app.state = "waiting-for-bite" @@ -246,15 +249,20 @@ def onStep(app): case "waiting-for-bite": app.fishingTimer -= 1 if app.fishingTimer < 1: - startSkillCheck(app, pickRandomCreature(app)) + selectedCreature = pickRandomCreature(app) + app.hookedFish = selectedCreature + startSkillCheck(app, selectedCreature) case "skill-check": app.skillCheckAngle += app.skillCheckSpeed + if (skillCheckAngle > 360): + finishSkillCheck(app) #list of interactables with name and their positions -#(name, left, right, top, bottom) +#(name, sceneFilter, left, right, top, bottom) INTERACTABLES = [ - ("") + ("open-shop", "idle", 250,350,0,100) + ("close-shop", "shop", 500, 550, 50, 100) ] def onMousePress(app, mouseX, mouseY): @@ -266,18 +274,24 @@ def onMousePress(app, mouseX, mouseY): # - shop / UI sprites clicked: open the shop or trigger that UI action. # Keep this as dispatch only - defer the real work to helper functions. match app.scene: - case "idle": + case "idle" | "shop": #also had to look this up - pipe operator is dumb. just let me have multiple cases interacted = False #check if we clicked a hud element/interactable - for name, left, right, top, buttom in INTERACTABLES: - if left < mouseX < right and top < mouseY < bottom: + for name, sceneFilter, left, right, top, buttom in INTERACTABLES: + if left < mouseX < right and top < mouseY < bottom \ + and sceneFilter == app.scene: interacted = True match name: - case "shop": - #... do something - pass - if not interacted: + case "open-shop": + app.scene = "shop" + case "close-shop": + app.scene = "idle" + if not interacted and app.scene == "idle": beginFishing(app) + case "result": + resetFishingState() + case "skill-check": + checkSkillHit(app) @@ -285,6 +299,8 @@ def onKeyPress(app, key): # Optional keyboard controls. Candidates: a key to cast/reel as an # alternative to clicking, a key to open/close the shop, or a debug/reset # key during development. Remove if you decide the game is mouse-only. + + #decidedly unused for now, i prefer mouse-only. ill keep the definition here in case i need debug tools. pass @@ -295,7 +311,19 @@ def checkSkillHit(app): # advance or fail the skill check accordingly. On full success, mark the # creature as caught and move to the catch-display phase; on failure, end # the cast without a catch. - pass + targetPos, targetLen = app.skillCheckBars.pop(0) + if not ( 0 < (app.skillCheckAngle - targetPos) < targetLen): #check if we hit a bar + #if we succeed, nothing needs to happen, we popped the bar + #if we fail, we either didnt hit or missed a past bar, either way we can jump straight to the fail screen + app.hookedFish = None + app.scene = "result" + + +def finishSkillCheck(app): + if len(app.skillCheckBars) > 0: + app.hookedFish = None #meaning we failed + app.scene = "result" + # ============================================================================= @@ -310,6 +338,8 @@ def sellCreature(app, creature): # difficulty (harder creatures pay more, per the spec). Persist the updated # money via writeSave. Decide here whether selling is automatic on catch or # a deliberate action in the shop/market. + + #selling is automatic pass diff --git a/time_log b/time_log index 27a3a07..1eee2ee 100644 --- a/time_log +++ b/time_log @@ -49,3 +49,11 @@ End Time: 1:20am Duration: 40 minutes Description: finish up (mostly) basic functions and move onto controller, work out a bunch of finer logic and complex math ############################################### + +############################################### +Date: 08-Oct +Start Time: 7:20pm +End Time: 1:20am +Duration: 40 minutes +Description: finish up (mostly) basic functions and move onto controller, work out a bunch of finer logic and complex math +###############################################