Jump to content

Anyone familiar with SFML - C++


Gatorade

Recommended Posts

^ If you are and you would be interested in eithor sharing some knowledge on how you came to learn it / be willing to write something for me I will pay you in game or real $ depending on your preference. No its not for HW its to finish a project that I couldn't complete last semester that my OCD is yelling at me for. (Serpinski's Triangle using SFML in C++ first for regular lines then for fractal lines)

This was the coding environment:

http://www.cs.uml.edu/~ahatem/sp16/comp2040/assign/ps0.html

This was the assignment I failed that was bothering me why I didnt understand it:

http://www.cs.uml.edu/~ahatem/sp16/comp2040/assign/ps1.html

Edited by Sugarfoot
Link to comment

Im taking a Comp Sci class, But were only learning in Java, If you want to know the basics I could show you some great sites to learn on, Most code platforms are very similar, Just sometimes they have different syntax. 

 

Whats the problem like?

Edited by David Ortega
Link to comment
12 minutes ago, David Ortega said:

Im taking a Comp Sci class, But were only learning in Java, If you want to know the basics I could show you some great sites to learn on, Most code platforms are very similar, Just sometimes they have different syntax. 

 

Whats the problem like?

Well its honestly retarded. Its this dog shit library where you are forced to use things preset to load in different graphics and sound with your files to create different types of games and things. Problem is half the stuff doesn;t work properly or its poorly explained inside of the SFML documents and website.

 

Its to the point where it really doesn't encorperate any foundations that C++ really should other then the fact that it uses alot of inheriting

 

Edit: I put the stuff in the first post for the environment and assignment to make it more clear then my explanation

Edited by Sugarfoot
Link to comment
1 minute ago, JackDilluz said:

It's pretty easy, hit me up in a PM if you need some starter help.

If you can figure out how to draw a serpinski's triangle in SFML using C++ ill pay you whatever you want in asylum money. Ive found code online that i tryed encorperating and running and none of it has worked. I use a linux type environment to run it. This was the assignment in the spring - I failed this one bad

http://www.cs.uml.edu/~ahatem/sp16/comp2040/assign/ps1.html

Link to comment

Wrote a script in Python to do it.  Obviously, this is not C++ nor the library you specified, but the logic and arithmetic will be the same.

'''
Author: Evan Otero (Googie)
Copyright (c) 2016 Evan Otero (Googie)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
'''

from Tkinter import *

def draw_gasket(x1, y1, x2, y2, nlevels):
    side = x2 - x1
    if nlevels == 0:
        canvas.create_polygon(x1, y2, .5 * side + x1, y1, x2, y2, fill='white', width=0)  # Draw Triangle
    else:
        draw_gasket(.25 * side + x1, y1, .75 * side + x1, .5 * side + y1, nlevels - 1)  # A
        draw_gasket(x1, .5 * side + y1, .5 * side + x1, y2, nlevels - 1)  # B
        draw_gasket(.5 * side + x1, .5 * side + y1, x2, y2, nlevels - 1)  # C

window = Tk()
window.title("Sierpinski's Gasket")
canvas = Canvas(window, width = 512, height = 512, highlightthickness = 0, bg = 'black')
canvas.grid(row=0, column=0)
draw_gasket(0, 0, 512, 512, int(raw_input('Please enter the number of levels of recursion: ')))
window.mainloop()

Here are screenshots showing it in action:Xx4Vs44.png

Link to comment
16 minutes ago, Googie said:

Wrote a script in Python to do it.  Obviously, this is not C++ nor the library you specified, but the logic and arithmetic will be the same.




'''

Author: Evan Otero (Googie)

Copyright (c) 2016 Evan Otero (Googie)



Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:



The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.



THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

'''



from Tkinter import *



def draw_gasket(x1, y1, x2, y2, nlevels):

    side = x2 - x1

    if nlevels == 0:

        canvas.create_polygon(x1, y2, .5 * side + x1, y1, x2, y2, fill='white', width=0)  # Draw Triangle

    else:

        draw_gasket(.25 * side + x1, y1, .75 * side + x1, .5 * side + y1, nlevels - 1)  # A

        draw_gasket(x1, .5 * side + y1, .5 * side + x1, y2, nlevels - 1)  # B

        draw_gasket(.5 * side + x1, .5 * side + y1, x2, y2, nlevels - 1)  # C



window = Tk()

window.title("Sierpinski's Gasket")

canvas = Canvas(window, width = 512, height = 512, highlightthickness = 0, bg = 'black')

canvas.grid(row=0, column=0)

draw_gasket(0, 0, 512, 512, int(raw_input('Please enter the number of levels of recursion: ')))

window.mainloop()

Here are screenshots showing it in action:Xx4Vs44.png

I tryed reverse engineering one from python on the internet and it came out terrible

Link to comment
11 minutes ago, Sugarfoot said:

I tryed reverse engineering one from python on the internet and it came out terrible

How so?  There really isn't a need to reverse engineer.  First, you need to understand how the program will work recursively.  All recursive functions have two main parts:

1. The Base Case: when do we want to stop

2. Else: what to do until we reach the base case

I imagine the library will require you to draw a polygon using coordinates.  Thus, a triangle will be made up of three coordinates (lower left, top, lower right), where each of those coordinates will be an X value and a Y value.  Our base case can be when we need to draw the big triangle, so it will just need the proper coordinates to do that (basic arithmetic will yield you that).

Now, we must figure out what to do until we reach the case were we need to draw the big triangle.  I find it best to look at it this way:

Imagine the next step beyond the big triangle.  That will be when there are three triangles inside the big triangle.  Let's call those A, B, C.  If we look closely, we see that each of these A's, B's, C's, will also contain three triangles.  Thus, it is a pattern.  So, theoretically, if we can tackle this first case of splitting the triangle into three triangles, then we solve the entire problem through recursion!

Now, through some geometry, you can figure out the coordinates of these three triangles.  Just pretend there is only one level of recursion to simply the problem in your head.  Then, you have to do what I consider the most important part of development/engineering: DEBUG!  Recursion requires a "leap of faith", as the concept can quickly go above one's understanding.  Trial and error is the key to solving problems such as these for beginners.  This is the best way to pick up the fundamentals of programming logic.

Link to comment
3 hours ago, Googie said:

How so?  There really isn't a need to reverse engineer.  First, you need to understand how the program will work recursively.  All recursive functions have two main parts:

1. The Base Case: when do we want to stop

2. Else: what to do until we reach the base case

I imagine the library will require you to draw a polygon using coordinates.  Thus, a triangle will be made up of three coordinates (lower left, top, lower right), where each of those coordinates will be an X value and a Y value.  Our base case can be when we need to draw the big triangle, so it will just need the proper coordinates to do that (basic arithmetic will yield you that).

Now, we must figure out what to do until we reach the case were we need to draw the big triangle.  I find it best to look at it this way:

Imagine the next step beyond the big triangle.  That will be when there are three triangles inside the big triangle.  Let's call those A, B, C.  If we look closely, we see that each of these A's, B's, C's, will also contain three triangles.  Thus, it is a pattern.  So, theoretically, if we can tackle this first case of splitting the triangle into three triangles, then we solve the entire problem through recursion!

Now, through some geometry, you can figure out the coordinates of these three triangles.  Just pretend there is only one level of recursion to simply the problem in your head.  Then, you have to do what I consider the most important part of development/engineering: DEBUG!  Recursion requires a "leap of faith", as the concept can quickly go above one's understanding.  Trial and error is the key to solving problems such as these for beginners.  This is the best way to pick up the fundamentals of programming logic.

So essentially you are starting with one big ass triangle probably the size of the window and recursively dividing it by an algorithm that takes n divisions and uses it to make sub triangles with three different variables, one for each vertex of the triangle?

Link to comment

googie is that how you communicate with your fellow members? "wrote in python ... "  from all the softwares you choose Python => a snake ? a snake with triangles on it's skin. triangles within triangles. every triangle is a role. triangiception. googie head of IlluminatiTee (IT) departement confirmed.

btw what does HW mean?

Link to comment
3 hours ago, Sugarfoot said:

So essentially you are starting with one big ass triangle probably the size of the window and recursively dividing it by an algorithm that takes n divisions and uses it to make sub triangles with three different variables, one for each vertex of the triangle?

Exactly!

3 hours ago, Sleepy said:

googie is that how you communicate with your fellow members? "wrote in python ... "  from all the softwares you choose Python => a snake ? a snake with triangles on it's skin. triangles within triangles. every triangle is a role. triangiception. googie head of IlluminatiTee (IT) departement confirmed.

btw what does HW mean?

HW stands for DDOS ASYLUM

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...