Hey there everyone!
I wanted to try and create some kind of "connect the dots" minigame in my VN but I have no idea what I should be trying to do to make it happen.
The game must be able to register if the user hit all the correct points
Something like if the user can connect point A to point B successfully (with perhaps multiple points in succession) then the user gets the green light etc.
My first idea was to look into some kind of drawing function like in this discussion:
viewtopic.php?t=51370
someone managed to figure out how to create straight lines, but i don't know how i'd be able to validate the points
but perhaps there's a simpler way to have a connect the dots game besides having some kind of drawing function... maybe using buttons or something
Any ideas would be appreciated, thanks!
Help with a "connect the dots" mini game?
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
- Per K Grok
- Miko-Class Veteran
- Posts: 882
- Joined: Fri May 18, 2018 1:02 am
- Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
- itch: per-k-grok
- Location: Sverige
- Contact:
Re: Help with a "connect the dots" mini game?
darxori wrote: ↑Mon Dec 09, 2019 12:00 am Hey there everyone!
I wanted to try and create some kind of "connect the dots" minigame in my VN but I have no idea what I should be trying to do to make it happen.
The game must be able to register if the user hit all the correct points
Something like if the user can connect point A to point B successfully (with perhaps multiple points in succession) then the user gets the green light etc.
My first idea was to look into some kind of drawing function like in this discussion:
viewtopic.php?t=51370
someone managed to figure out how to create straight lines, but i don't know how i'd be able to validate the points
but perhaps there's a simpler way to have a connect the dots game besides having some kind of drawing function... maybe using buttons or something
Any ideas would be appreciated, thanks!
I did make a minigame like that for my game Defenders of Adacan - part 1 the Ascent. https://per-k-grok.itch.io/defenders-of-adacan
Here is a test of the game built with pygame
later adopted to run in ren'py.
I have a class to draw the lines. I have imported pygame to use pygame.draw.line
Code: Select all
init python:
class LineDisplay(renpy.Displayable):
def __init__(self, *args, **kwargs):
super(LineDisplay, self).__init__(*args, **kwargs)
def render(self, width, height, st, at):
screen = renpy.Render(640, 480)
can=im.load_surface("images/blankcanvas.png")
x= len(list_lines)
y=0
while y<x:
pygame.draw.line(can,(0,0,255),list_lines[y][0], list_lines[y][1], 3)
y += 1
screen.blit(can,(0,0))
renpy.redraw(self, 0)
return screen
I have a list with the points that are clickable.
I have a function to check if a click is sufficiently close to one of the clickable points. Requires import math and disable Side Rollback(if any clicks could be in rollback area.)
Code: Select all
def inCircle(pointX, pointY,gX,gY,distance):
xDist = pointX-gX
xDist=math.fabs(xDist)
yDist = pointY-gY
yDist=math.fabs(yDist)
xyDist = (xDist*xDist)+(yDist*yDist)
if distance >= math.sqrt(xyDist):
return True
else:
return False
The first click close enough to a clickable point will store the value of that point in the variable startPoint. i.e startpoint= (210, 120)
The second click will store the value in the variable secondPoint.
startPoint and secondPoint will be stored in the variable twoPoints that is appended to the list, list_lines.
LineDisplay will draw the lines in that list.
When twoPoints are appended to list_lines secondPoint becomes the new startPoint and the next click will give us a new secondPoint.
-
- Newbie
- Posts: 7
- Joined: Fri Mar 01, 2024 5:49 pm
- Contact:
Re: Help with a "connect the dots" mini game?
could you show more of how this minigame's code is set up, or give an example how to setup up a simple one if you can please.I did make a minigame like that for my game Defenders of Adacan - part 1 the Ascent. https://per-k-grok.itch.io/defenders-of-adacan
Here is a test of the game built with pygame
later adopted to run in ren'py.
I have a class to draw the lines. I have imported pygame to use pygame.draw.line
Code: Select all
init python: class LineDisplay(renpy.Displayable): def __init__(self, *args, **kwargs): super(LineDisplay, self).__init__(*args, **kwargs) def render(self, width, height, st, at): screen = renpy.Render(640, 480) can=im.load_surface("images/blankcanvas.png") x= len(list_lines) y=0 while y<x: pygame.draw.line(can,(0,0,255),list_lines[y][0], list_lines[y][1], 3) y += 1 screen.blit(can,(0,0)) renpy.redraw(self, 0) return screen
I have a list with the points that are clickable.
I have a function to check if a click is sufficiently close to one of the clickable points. Requires import math and disable Side Rollback(if any clicks could be in rollback area.)
You could use buttons instead (or hotspots).Code: Select all
def inCircle(pointX, pointY,gX,gY,distance): xDist = pointX-gX xDist=math.fabs(xDist) yDist = pointY-gY yDist=math.fabs(yDist) xyDist = (xDist*xDist)+(yDist*yDist) if distance >= math.sqrt(xyDist): return True else: return False
The first click close enough to a clickable point will store the value of that point in the variable startPoint. i.e startpoint= (210, 120)
The second click will store the value in the variable secondPoint.
startPoint and secondPoint will be stored in the variable twoPoints that is appended to the list, list_lines.
LineDisplay will draw the lines in that list.
When twoPoints are appended to list_lines secondPoint becomes the new startPoint and the next click will give us a new secondPoint.
Re: Help with a "connect the dots" mini game?
Per K Grok wrote: ↑Mon Dec 09, 2019 2:03 pmdarxori wrote: ↑Mon Dec 09, 2019 12:00 am Hey there everyone!
I wanted to try and create some kind of "connect the dots" minigame in my VN but I have no idea what I should be trying to do to make it happen.
The game must be able to register if the user hit all the correct points
Something like if the user can connect point A to point B successfully (with perhaps multiple points in succession) then the user gets the green light etc.
My first idea was to look into some kind of drawing function like in this discussion:
viewtopic.php?t=51370
someone managed to figure out how to create straight lines, but i don't know how i'd be able to validate the points
but perhaps there's a simpler way to have a connect the dots game besides having some kind of drawing function... maybe using buttons or something
Any ideas would be appreciated, thanks!
I did make a minigame like that for my game Defenders of Adacan - part 1 the Ascent. https://per-k-grok.itch.io/defenders-of-adacan
Here is a test of the game built with pygame
later adopted to run in ren'py.
I have a class to draw the lines. I have imported pygame to use pygame.draw.line
Code: Select all
init python: class LineDisplay(renpy.Displayable): def __init__(self, *args, **kwargs): super(LineDisplay, self).__init__(*args, **kwargs) def render(self, width, height, st, at): screen = renpy.Render(640, 480) can=im.load_surface("images/blankcanvas.png") x= len(list_lines) y=0 while y<x: pygame.draw.line(can,(0,0,255),list_lines[y][0], list_lines[y][1], 3) y += 1 screen.blit(can,(0,0)) renpy.redraw(self, 0) return screen
I have a list with the points that are clickable.
I have a function to check if a click is sufficiently close to one of the clickable points. Requires import math and disable Side Rollback(if any clicks could be in rollback area.)
You could use buttons instead (or hotspots).Code: Select all
def inCircle(pointX, pointY,gX,gY,distance): xDist = pointX-gX xDist=math.fabs(xDist) yDist = pointY-gY yDist=math.fabs(yDist) xyDist = (xDist*xDist)+(yDist*yDist) if distance >= math.sqrt(xyDist): return True else: return False
The first click close enough to a clickable point will store the value of that point in the variable startPoint. i.e startpoint= (210, 120)
The second click will store the value in the variable secondPoint.
startPoint and secondPoint will be stored in the variable twoPoints that is appended to the list, list_lines.
LineDisplay will draw the lines in that list.
When twoPoints are appended to list_lines secondPoint becomes the new startPoint and the next click will give us a new secondPoint.
Renpy textbook (in Russian). https://disk.yandex.ru/i/httNEajU7iFWHA (all information is out of date) Update 22.06.18
Sawa - a game of the Drow Nation
Honest Critique
Poses in visual novels, or how to hold a character properly in the frame
Help save articles to the webarchive. [/color]
Sawa - a game of the Drow Nation
Honest Critique
Poses in visual novels, or how to hold a character properly in the frame
Help save articles to the webarchive. [/color]
Who is online
Users browsing this forum: Google [Bot]