• Breaking News

    Friday, November 2, 2018

    I've completed freeCodeCamp and Received all the certifications. Here are few things I want to tell you learn programming

    I've completed freeCodeCamp and Received all the certifications. Here are few things I want to tell you learn programming


    I've completed freeCodeCamp and Received all the certifications. Here are few things I want to tell you

    Posted: 01 Nov 2018 06:50 AM PDT

    Hi. I started freeCodeCamp in April of this year, coded 2 hours a day on average and finished the whole thing mid October.

    For those of you who are just starting out their journey to web development and programming in general, Here are a few things I'd like to say

    • Learn how to read documentation because you'll have to look into documentations. A LOT.
    • freeCodeCamp teaches you programming via hand-on practical approach. Complement it by reading good articles or official documentations or a book if you want in depth knowledge about certain frameworks or technology.
    • Here are a few things you'll have to learn on your own
      • Git
      • SQL and Relational Database Design
      • Creating a full MERN Stack application (Brad Traversy has excellent free tutorial videos on this on YouTube)
      • Deploying your projects to production
      • Using Visual Studio Code or any editor outside of coding sandboxes like glitch and codepen
      • Basic terminal usage and bash
    • Projects will take the most amount of time. Projects are where you'll learn the most.
    • Sometimes I had to go through a section multiple times to properly understand something. Take your time and don't get frustrated if something doesn't make sense on first glance.
    • Whatever you learn, Consistency is more important than pace..
    • freeCodeCamp or any resource for that matter will not make you a complete web developer just by completing projects and getting certifications, it helps, but you will have to continue learning and implementing what you've learned.
    • If you are not interested in Node.js on back-end then another excellent resource is The Odin Project however I would still suggest everyone to learn the front-end stuff from freeCodeCamp first.

    Your completion time might differ from mine since I had some programming experience beforehand. I've been working on a side project now for a couple of weeks to enhance my portfolio and I am applying for positions in my area and remote position but haven't found any luck yet. Finally, If you are just starting out, I hope this helps you out a little. And I wish you Good Luck!

    My freeCodeCamp profile for proof of-course:

    https://www.freecodecamp.org/ozarion

    You might see that my heatmap is a bit inconsistent and the reason is, my older account got deleted when freeCodeCamp was switching to the new curriculum, the support team was very helping and they did restore it but I had made a new account then.

    Quotes from a random quote machine I built as one of the projects:

    * Sometimes you'll get headaches. Muscles hurt when you workout. (Your Brain is a muscle)

    * Redux is NOT confusing. You'll really appreciate Redux when you start working on a big project

    * Undefined

    submitted by /u/cozarion
    [link] [comments]

    Learn JSON in 10 Minutes

    Posted: 01 Nov 2018 04:04 PM PDT

    If you haven't already become familiar with JSON, I highly recommend you checkout this video on JSON.

    JSON is one of the most important "languages" any programmer can learn, because it is used across many different types of software development, such as web development, game development, and many more. It is also fairly straight forward and easy to understand, which makes it great for anyone just starting out.

    This video will cover what JSON is, why it is important, the syntax/types of JSON, and multiple examples of JSON.

    submitted by /u/Nebs987
    [link] [comments]

    What is the best Resource to learn Asp.net MVC5 for a beginner or for a PHP programmer?

    Posted: 01 Nov 2018 11:12 PM PDT

    I am kind of a PHP programmer that never used asp.net mvc, what is the best resource to learn advanced c# for asp.net mvc and also how to develop asp.net mvc web applications?

    submitted by /u/hajiman2
    [link] [comments]

    Getting good at algorithms and design patterns?

    Posted: 01 Nov 2018 10:59 PM PDT

    What resources do you recommend to improve those skills?

    submitted by /u/Theminimalist_H
    [link] [comments]

    How do I start learning data analysis?

    Posted: 01 Nov 2018 10:47 PM PDT

    This field of data analysis caught my interest for a while and I decided I want to learn it. However I don't know where to start.

    submitted by /u/zuco20001
    [link] [comments]

    Alpha beta optimization for a simple game

    Posted: 01 Nov 2018 08:11 PM PDT

    (Apologies, in hindsight the post is kinda long.)

    The game's git repo

    Sample game (displays some of what's going on while it's computing)

    My Python code (I'm sorry it's very messy, I'm still learning good programming practices :) )

    TL;DW , what's the game ? : A python and a rat controlled by AIs are fighting for cheeses in a maze. Your goal is to capture as much as possible.

    Hey /r/learnprogramming !

    I'm at the end of a discrete mathematics and algorithmics course, and the course is to be concluded by a tournament between students' AIs.

    I chose to base my on Alpha beta pruning and optimize it as much a s possible to win the tournament !

    I do have a (I believe) working implementation that returns a move in time with iterative deepening, transposition table and refutation table implemented. If anyone can find a mistake in my implementation please do signal it !

    It's able to search to a depth of 30-40 on average given 1 second of thinking time, but i still need to make it faster, for 2 reasons:

    1. I'm able to make it work and play fairly well against a greedy algorithm (goes to the nearest cheese piece) on small mazes (about 9x9 dimension) and without any mud (inflates distances between cheeses), but it blunders too frequently for my liking on bigger mazes and with mud. I believe it's because of the cheeses being more far away from each other and the paths being longer, making the alg not see the deeper lines of play where it would be losing.
    2. The tournament is going to be held with 2 seconds of preprocessing (same parameter as my tests) but only 100ms of thinking time per turn (as opposed to the 1 second i gave in the tests).

    All in all,I think the speed/search efficiency department needs a major boost. I looked into a few things:

    • Pure alpha-beta optimizations:
      • Null-move heuristic : This one looks perfect for this game since I can't imagine a situation where wasting a move could help a player.
        • But how would this be implemented ? And how much improvement should i expect ? And furthermore i understand the idea, but why is it effective ?
        • How would I implement this without wasting time ?
      • Better move ordering : I looked into the history heurstic, which this paper (J. Schaeffer, The history heuristic and alpha-beta search in practice) says combined with the transposition table is very effective.
        • Would it work as well here as it could in chess ? If i understand it well, in chess for each move you can do with each piece, you store a score depending on how often it is chosen as a best move and the depth of the tree searched. I can understand why moving a rook to the ennemy's backline has a high probability to be a good move, but in this game we only have 2 pieces, with at best 4 moves each. Or maybe you store more specifics than just the pieces and a move, but what would be relevant ? it should be situtations that are frequent enough to have relevant scoring, but not too much for its information to be useful enough right ? And it should be situations that the tree encounters relatively often too, or else I'm wasting computing time
        • How do I implement this ? This would require me to keep move lists ordered, and since this would be called often, I would this to be fast. What data structure would be adequate ? Some kind of priority queue ?
    • Coding optimizations. I'm still learning Python, I'm sure a lot of it is not optimal and can be optimized.
      • Alpha-beta search body : line 266 in the code
      • Function to create a child node given a move : line 196
      • Move ordering functions are in the Moves class : line 42
      • tables of all sort are handled using cachetools' library Least Frequently Used cache : line 23
      • Iterative deepening calls function : line 340
      • preprocessing function , performs some preprocessing in the time allowed : line 369
      • turn function , called at each turn of play for both players. receives information relative to the maze, and both players' locations and scores, aswell as a list containing the remaining pieces of cheese locations. Returns the chosen move for that turn.
      • preturn function : line 386
      • timeUp function ,for time keeping : line 242

    Last question and probably the easiest part to fix but i can't get it to work for some reason .

    The maze is represented as a graph as basically an adjacency matrix with distances from 1 to something like ten. The distance indicates in how many turns the player will be allowed to move, e.g. if the distance is 1 the player will be able to move next turn, and 9 turns if the distance is 10. I keep track of this variable to launch the feed them to the alpha beta search.

    To keep track of this variable, I wrote the preturnfunction. I have 2 global variables called current_player1_penalty and current_player_2 penalty and the location histories for both players and the call maze_graph[previous_node][new_node] gives me the distance between both nodes. How would you update the penalties for both players at the start of each turn ?

    I keep getting the error "Nodes are not connected" meaning the previous node that's stored in the global variable and the player's current position are not adjacent in the maze. I'm probably fucking up the updating of the positions but I don't know where.

    Any input is very much appreciated !

    Thanks !

    submitted by /u/Mintiti
    [link] [comments]

    Software Developer at JetBrains, studying CS. Any native english speakers interested in teaching me english in exchange for learning programming?

    Posted: 01 Nov 2018 07:52 AM PDT

    I 've been teaching programming at weekends for a few years. I'd also like to improve my english conversation skills.

    My idea is that we would split the time 1:1 - just chatting with each other, you correcting my mistakes & me teaching you programming/algorithmization/specific language of your choice/etc.

    Anyone interested?

    submitted by /u/turbulent64
    [link] [comments]

    What are the best project based programming tutorials on YouTube?

    Posted: 01 Nov 2018 11:25 PM PDT

    I wanted to subscribe to youtube tutorial videos for programming which are project based.

    submitted by /u/hajiman2
    [link] [comments]

    Trying to return two arrays, but they combine instead of returning separately. How do i fix it?

    Posted: 01 Nov 2018 07:32 PM PDT

    function findCenter(array){

    var latArray = [];

    var longArray = [];

    var latitude = [];

    var longitude = [];

    for (var values of array){

    latitude.push(values[0]);

    longitude.push(values[1]);

    }

    var maxLat = Math.max.apply(Math, latitude)

    var minLat = Math.min.apply(Math, latitude)

    var maxLong = Math.max.apply(Math, longitude)

    var minLong = Math.min.apply(Math, latitude)

    var centerLat = [(minLat + maxLat) / 2]

    var centerLong = [(minLong + maxLong) /2]

    return centerLat + centerLong

    }

    console.log(findCenter([[20.3,-56.8,"test point 1"],[26.3,-59.8,"test point 2"],[21.3,-50.8,"test point 3"]]))

    I want it to return 2 arrays, [centerLat],[centerLong], but it just returns one :/

    submitted by /u/coledsprouts
    [link] [comments]

    Really bored with programming... I need a new hobby.

    Posted: 01 Nov 2018 10:55 PM PDT

    I made a bunch of things with code including a sleek stopwatch, a maze game, a simple 2D endless runner game, a test your psychic ability game, an automatic file renamer. At this point, I am kind of bored with programming and not really feeling any passion. What should I do?

    submitted by /u/GoodProgrammer2018
    [link] [comments]

    Anyone know SQL? I need help adding a table with a price increase

    Posted: 01 Nov 2018 10:55 PM PDT

    Hi! I need help creating the following item in SQL:

    I have to show a 15% increase of a value in a new table, and my end result should show the original value, and the new increased value side-by-side.

    Need to know within 20-30 minutes! Thanks!

    submitted by /u/broncoanonymous
    [link] [comments]

    Background Hero Video issues

    Posted: 01 Nov 2018 10:26 PM PDT

    So I am having a few different issues when it comes to this and I am coming to hopefully get some clarity as I seeing things all over the place online.

    1. When using a video I know that you need to set its aspect ratio, is it possible for this to be responsive to take up the full screen at various sizes? Im basically trying to make the video take up the full page of whats being scene.

    2. The current image has the text as part of the image, I am curious in order to keep the text always in view it needs to be responsive. In theory could this text (likely being used as a SVG perhaps) be used so that I could shrink it down in order to always stay in view?

    Here is the test site I have been working on: https://tsukiyonocm.github.io/test/

    If you go full screen you can see the video, the person I am doing this for would like the video used at all sizes, though I am just not sure if thats possible.

    Currently at mobile it switches to an image for a placeholder. Though while typing this I might have thought on how best to handle that portion anyway.

    submitted by /u/Tsukiyonocm
    [link] [comments]

    [Java SDK8] Why do I get a null pointer exception in this program, even though the integer array has been initialized?

    Posted: 01 Nov 2018 10:25 PM PDT

    import javafx.animation.KeyFrame; import javafx.animation.Timeline; import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import javafx.scene.paint.Color; import javafx.stage.Stage; import javafx.util.Duration; public class Window extends Application{ public static final int WINDOW_WIDTH = 500; public static final int WINDOW_HEIGHT = 500; public static Scene scene; Automator automate; Player main; public void start(Stage theStage) { Group root = new Group(); scene = new Scene(root, WINDOW_WIDTH, WINDOW_HEIGHT); Canvas canvas = new Canvas(WINDOW_WIDTH, WINDOW_HEIGHT); GraphicsContext gc = canvas.getGraphicsContext2D(); root.getChildren().add(canvas); theStage.setScene(scene); CellGrid objGrid = new CellGrid(WINDOW_WIDTH, WINDOW_HEIGHT, canvas, automate, main); automate = new Automator(objGrid); main = new Player(20, 20, automate); main.pos[0] = 25; main.pos[1] = 25; main.gc = canvas.getGraphicsContext2D(); main.sc = scene; main.eventListener(objGrid, main); theStage.show(); Timeline tl = new Timeline(); tl.setCycleCount(tl.INDEFINITE); tl.setRate(.5); KeyFrame key = new KeyFrame(Duration.millis(1000/60), e-> { gc.clearRect(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT); automate.updateLastPos(); main.iterate(objGrid); drawGrid(gc); });tl.getKeyFrames().add(key); tl.play(); } public void drawGrid(GraphicsContext gc) { for(int i = 0; i < WINDOW_WIDTH/5; i++) { for(int j = 0; j < WINDOW_HEIGHT/5; j++) { gc.setFill(Color.GREY); gc.strokeLine(i*5, i*5, i*5, j*5); gc.strokeLine(i*5, i*5, j*5, i*5); } } } public static void main(String[] args) { launch(args); } } class Player { boolean up_x; boolean up_y; boolean down_x; boolean down_y; int width; int height; public int[] pos = new int[2]; Scene sc = Window.scene; GraphicsContext gc; Automator auto; public void iterate(CellGrid c) { gc.setFill(Color.BLUE); gc.fillRect(pos[0] * 5, pos[1] * 5, 5, 5); adjustPos(); c.iterate(); } public void adjustPos() { if(up_x == true) pos[1]++; if(down_x == true) pos[1]--; if(up_y == true) pos[0]++; if(down_y == true) pos[0]--; } Player(int x, int y, Automator a) { pos[0] = x; pos[1] = y; this.auto = a; } public void eventListener(CellGrid c, Player p) { sc.setOnKeyPressed(e->{ if(e.getCode().equals(KeyCode.SPACE)) c.addCell(p.pos[0], p.pos[1]); if(e.getCode().equals(KeyCode.BACK_SPACE)) c.removeCell(this.pos[0], this.pos[1]); auto.listener(e); if(e.getCode().equals(KeyCode.A)) { down_y = true; } if(e.getCode().equals(KeyCode.D)) { up_y = true; } if(e.getCode().equals(KeyCode.W)) { down_x = true; } if(e.getCode().equals(KeyCode.S)) { up_x = true; } }); sc.setOnKeyReleased(f-> { if(f.getCode().equals(KeyCode.A)) { down_y = false; } if(f.getCode().equals(KeyCode.D)) { up_y = false; } if(f.getCode().equals(KeyCode.W)) { down_x = false; } if(f.getCode().equals(KeyCode.S)) { up_x = false; } }); } } class CellGrid { int width; int height; int[][] pos; Scene scene; GraphicsContext gc; Canvas canvas; Automator auto; Player main; CellGrid(int width, int height, Canvas c, Automator a, Player m) { this.canvas = c; this.width = width; this.height = height; pos = new int[width/5][height/5]; gc = canvas.getGraphicsContext2D(); auto = a; main = m; } public void addCell(int x, int y) { pos[x][y] = 1; } public void removeCell(int x, int y) { pos[x][y] = 0; } public void iterate() { for(int i = 0; i < (width/5); i++) { for(int j = 0; j < (height/5); j++) { if(main.pos[0] != i && main.pos[1] != j) { if(this.pos[i][j] == 1) { gc.setFill(Color.RED); gc.fillRect(i*5, j*5, 5, 5); } if(this.pos[i][j] == 0) { gc.setFill(Color.PURPLE); gc.fillRect(i*5, j*5, 5, 5); } } } } } } class Automator { int width = Window.WINDOW_WIDTH; int height = Window.WINDOW_HEIGHT; int[][] lastPos = new int[width/5][height/5]; int[][] nextPos = new int[width/5][height/5]; int[][] savedPos = new int[width/5][height/5]; CellGrid cells; Automator(CellGrid c) { this.cells = c; } public void updateCellGrid() { cells.pos = lastPos.clone(); } public void updateLastPos() { this.lastPos = cells.pos.clone(); } public void listener(KeyEvent e) { /**Window.scene.setOnKeyPressed(e-> { if(e.getCode().equals(KeyCode.Q)) { savedPos = lastPos.clone(); } if(e.getCode().equals(KeyCode.E)) { iterateCells(); } } );**/ if(e.getCode().equals(KeyCode.Q)) { updateLastPos(); savedPos = lastPos.clone(); } if(e.getCode().equals(KeyCode.E)) { updateLastPos(); //clone CellGrid pos to Automator's pos iterateCells(); //Count neighbors, and change state based on that updateCellGrid(); //update the cell grid } if(e.getCode().equals(KeyCode.T)) { lastPos = savedPos.clone(); updateCellGrid(); } } public void iterateCells() { for(int x = 0; x < (100) - 1; x++) { for(int y = 0; y < (100) - 1; y++) { if(neighbors(x, y) < 3 && neighbors(x,y) > 7) nextPos[x][y] = 0; if(neighbors(x,y) > 3 && neighbors(x,y) <= 7) nextPos[x][y] = 1; } } System.out.println(neighbors(1, 1)); lastPos = nextPos.clone(); updateCellGrid(); } public int neighbors(int x, int y) { int neighbors = 0; if(x > 0 && x < width-1 && y > 0 && y < height-1) { for(int i = -1; i < 1; i++) { for(int j = -1; j < 1; j++) { if(lastPos[x + i][y + j] == 1) neighbors++; } } } if(lastPos[x][y] == 1) neighbors--; return neighbors; } } 

    this is the error I get:

    Exception in thread "JavaFX Application Thread" java.lang.NullPointerException at CellGrid.iterate(Window.java:211) at Player.iterate(Window.java:103) at Window.lambda$0(Window.java:55) at com.sun.scenario.animation.shared.TimelineClipCore.visitKeyFrame(TimelineClipCore.java:239) at com.sun.scenario.animation.shared.TimelineClipCore.playTo(TimelineClipCore.java:180) at javafx.animation.Timeline.impl_playTo(Timeline.java:176) at javafx.animation.AnimationAccessorImpl.playTo(AnimationAccessorImpl.java:39) at com.sun.scenario.animation.shared.InfiniteClipEnvelope.timePulse(InfiniteClipEnvelope.java:110) at javafx.animation.Animation.impl_timePulse(Animation.java:1102) at javafx.animation.Animation$1.lambda$timePulse$25(Animation.java:186) at java.security.AccessController.doPrivileged(Native Method) at javafx.animation.Animation$1.timePulse(Animation.java:185) 

    This is only my third semester of taking programming courses so excuse anything too stupid. I initialized the main.pos[] array in the start method of the Window class. I don't understand why I am getting a Null Pointer Exception, I asked a colleague and he didn't know either. I am honestly stuck. Any help appreciated, thank you.

    submitted by /u/x1expert1x
    [link] [comments]

    MongoDB Tutorial

    Posted: 01 Nov 2018 10:06 PM PDT

    MongoDB is a high-performance, highly scalable, easy to deploy, easy to use, and easy to store NoSQL database, which is ideal for inserting, updating and querying data in real time. It is used in scenarios where the performance requirements of the database are high, the flexibility requirements are stronger, and the data model is relatively simple. This tutorial will lead you to learn MongoDB.

    link: https://labex.io/courses/mongodb-tutorial

    submitted by /u/brycehu24
    [link] [comments]

    When using Electron, what is the best way to design the HTML/CSS layout?

    Posted: 01 Nov 2018 10:01 PM PDT

    Do most people just manually type the values in? Or is there some type of UI builder similar to Android/iOS drag and drop UI builder? Like I know even most websites now a days don't have you manually type in the HTML instead using some type of site builder.

    submitted by /u/subnub99
    [link] [comments]

    Issue with scanf

    Posted: 01 Nov 2018 09:33 PM PDT

    This code is trying to get a user input as a long long but it will not move onto the next line of code after the scanf function when I input the next line key (enter). How do I keep this infinite loop from happening?

    long long userInput(void) { //Local Declaration long long input; //The user inputed integer to rotate input = 0; //Executable statements //Get user input printf("Enter integer to rotate -> "); scanf("%lld", &input); printf("\n"); //Formatting //Check if input is positive and get new input if it's not while (input <= 0) { printf("Error! Positive integers only!!\n\n"); printf("Enter integer to rotate -> "); scanf("%lld", &input); printf("\n"); //Formatting printf("statment"); } return input; } 

    As a side note I can only use the scanf function for user input since we have not learned fgets or gets yet. Thanks!

    submitted by /u/NRUCSGO
    [link] [comments]

    Object Literal - Change Calculator (Problem)

    Posted: 01 Nov 2018 08:59 PM PDT

    What I need to do: The getNumber method should accept a divisor parameter (like 25 for quarters), calculate the number of coins of that type that are required, update the cents property with the remaining cents, and return the number of coins.

    What I currently have done is, I went ahead and set up the getNumber method with the divisor parameter.

    What I need help with: What I'm unsure how to do is calculate the number of coins of that type that are required and how to update the cents property with the remaining cents.

    Help regarding how to set the code up to accomplish this would be much appreciated.

    Current Code: https://jsfiddle.net/3sdn8t46/2/

    submitted by /u/UnifiedOblivion
    [link] [comments]

    Using certain methodology for software development

    Posted: 01 Nov 2018 08:45 PM PDT

    So, I recently got lessons about methodologies for software development and given example like Scrum, Unified Process, Extreme Programming, etc.

    We haven't gone past that, but what I want to know is, how do we applying those methodologies? Is it applied on coding level or on the level of how the software work?

    submitted by /u/Trinity_souls
    [link] [comments]

    I want to get a better theoretical understanding of software

    Posted: 01 Nov 2018 08:35 PM PDT

    I have decent theoretical knowledge of hardware and how you could in principle make a computer from transistors, but operating systems, kernels, how programs actually communicate, and how the internet works are all not very clear to me.

    I also have operational knowledge of using Linux commands and writing code for scripts relevant to my work, but once it gets to scraping things off the internet or communicating with the computer in a non-trivial way I don't really know what I'm doing.

    Are there good textbooks or a series of textbooks that are oriented towards this? I'm not looking to become an expert, programming is only supplementary to my career, not it's goal. I'd prefer some level of technical detail above heuristic flow-charts, but not specific details on how to perform certain tasks. Something that would let me see the forest from the trees.

    Edit

    submitted by /u/connornm77
    [link] [comments]

    I feel like a worthless failure of a programmer

    Posted: 01 Nov 2018 08:01 PM PDT

    3rd Year CMPS student, just got done giving up on a project because I am so unbelievably stressed out and feel like a total idiot working on it.

    I'm doing data structures and shit(Trees if anyone cares) and I just feel worthless, we have some provided code and i'm so confused and lost tracing through it and since it's due in an hour in addition to having my calc exam tomorrow and a stats exam tomorrow I literally just can't. My brain deleted itself, it gave up.

    I feel like I shouldn't even be getting frustrated over this, and i'm just being a weakling for giving up and getting frustrated over something that's suppose to be a job that I like eventually and learn to enjoy the problem solving process, but when you spend 4 days literally getting nothing accomplished because you're so hard stuck on editing some prexisting code as they have told you to do, only to realize you can do the same thing making your own in like 10 lines it's really infuriating and just not very fun honestly.

    Maybe i'm just not cut out for this, I use to think I was smart in this shit, but now I'm pretty sure I'm just a fucking phony with not the slightest idea what I'm doing, this semester has ruined like so much of my confidence coding, and even when I start to get something, another thing comes out and smacks me across the face and says, "NO YOU"RE A DUMBASS SIT DOWN".

    I know this isn't a rant sub, but like, it's just a really frustrating process and I feel like a weakling for even finding it frustrating when I should probably be enjoying it, and just, I don't know if I am anymore.

    I'm sorry

    submitted by /u/ZygenX
    [link] [comments]

    Pygame - I can't get my sprite to move

    Posted: 01 Nov 2018 01:45 PM PDT

    Evening all,

    I decided to start messing around in Pygame after dabbling in a text-based RPG in python. I thought I'd start with being able to move a rectangle around the screen. Once I've nailed that, I can look try adding walls and so on. So far I've managed to draw a blue rectangle but it always appears in the top left and I can't move it. I get an error which says that the "video system not initialized". From what I can tell, this generally happens when pygame's init() has not been called.

    I am completely stumped. I have compared to some other code and I can't see where mine's going all wonky. Code reproduced in full below. Any ideas where this is going wonky?

    import pygame as pygame import time WIDTH = 800 HEIGHT = 640 TILE = 32 GRID_WIDTH = WIDTH / TILE GRID_HEIGHT = HEIGHT / TILE FPS = 30 WHITE = (255, 255, 255) BLACK = (0, 0, 0) RED = (255, 0, 0) GREEN = (0, 255, 0) BLUE = (0, 0, 255) PLAYER_SPEED = 100 class Game: def \_\_init\_\_(self): self.width = WIDTH self.height = HEIGHT self.tile = TILE self.fps = FPS self.grid\_height = self.height / self.tile self.grid\_width = self.width / self.tile self.all\_sprites = pygame.sprite.Group() def create\_window(self): pygame.init() pygame.mixer.init() self.screen = pygame.display.set\_mode((self.width, self.height)) self.clock = pygame.time.Clock() def new(self): self.player = Player(self, 3, 3) self.all\_sprites.add(self.player) def update(self): self.all\_sprites.update() def events(self): for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() keystate = pygame.key.get\_pressed() if keystate\[pygame.K\_ESCAPE\]: pygame.quit() def draw(self): self.screen.fill(BLACK) for sprite in self.all\_sprites: self.screen.blit(sprite.image, sprite.image.get\_rect()) pygame.display.flip() def game\_loop(self): self.create\_window() self.new() self.running = True while self.running: self.dt = self.clock.tick(self.fps) / 1000 self.update() self.draw() self.events() class Player(pygame.sprite.Sprite): def \_\_init\_\_(self, game, x, y): self.game = game pygame.sprite.Sprite.\_\_init\_\_(self) self.image = pygame.Surface((TILE, TILE)) self.image.fill(BLUE) self.rect = self.image.get\_rect() self.x = x \* TILE self.y = y \* TILE self.vx = 0 self.vy = 0 def handle\_event(self): self.vx = 0 self.vy = 0 keystate = pygame.key.get\_pressed() if keystate\[pygame.K\_LEFT\]: self.vx = -PLAYER\_SPEED elif keystate\[pygame.K\_RIGHT\]: self.vx = PLAYER\_SPEED elif keystate\[pygame.K\_UP\]: self.vy = -PLAYER\_SPEED elif keystate\[pygame.K\_DOWN\]: self.vy = PLAYER\_SPEED def update(self): self.handle\_event() self.x += self.vx \* self.game.dt self.y += self.vy \* self.game.dt game = Game() game.game_loop() 
    submitted by /u/FratmanBootcake
    [link] [comments]

    learn MySQL via vagrant

    Posted: 01 Nov 2018 07:35 PM PDT

    hi all, I'm trying to learn the MySQL via command line. So I set up a VM with vagrant (pretty new to this, but it's the ubuntu trusty 64 box). And I've gathered the basic commands to set up a LAMP server, but when I go to enter MySQL it gives me an auth error--even though I'm setting the user and pw in the vagrant file on "vagrant up". Any tips on what might be going awry? Would my zonealarm firewall on my host machine be an issue? Thanks!

    submitted by /u/mogla
    [link] [comments]

    Creating logins

    Posted: 01 Nov 2018 07:29 PM PDT

    TL;DR: How would I go about making a loging system for my website (Hopefully an alternative to MySQL and PhpMyAdmin

    Im 13, so I'm by no means fluent in any language (except maybe C++, but still) I am good at a few though notably: C++, HTML + CSS, JS, and Python. I have been moving away from desktop, however, because I want my family to be able to interact with what I make. HTML was an easy way to do such from my days when I was ten trying to make a minecraft server I already knew how to port forward so that wasn't hard, but then, I came to my challenge my websites were GARB like just text on a stretched out picture garb! So I quickly found a solution Materilaze CSS (I like it better because it came from MIT). Then I was rolling again. Now that I have a front page and a login page designed I was wondering how I could actually let people make an account and Log In. Any help is appreciated thanks for taking your time to help someone else. (Not to guilt anyone who doesn't)

    submitted by /u/BeigeGnat
    [link] [comments]

    [C++]need help printing the sum of columns in a matrix

    Posted: 01 Nov 2018 07:29 PM PDT

    Hi everyone, I'm new to programming and English isn't my first language so bear with me. I was assigned a homework in which I must make a program that generates a random number of votes and print them, that much is done, however one part of my homework states that after printing a matrix with the random numbers/votes, the program must print the sum of each individual column, for example:

    if my matrix is

    [ 1 4 7]

    [ 2 5 8]

    [ 3 6 9] then my program should show: [6 15 24],however when I execute my program the first sum is always wrong and the third one prints a random number. I've been liking programming so far but this bad boy has been given me trouble for the past few hours, any help is appreciated and again sorry if my English isn't my best.

    #include<stdio.h> #include<stdlib.h> #include<ctype.h> #include<windows.h> #include<time.h> #define fil 5 #define col 7 main(){ srand(time(NULL)); int mat[fil][col],i,j,fac,can; int votos[col]; int min=100,max=-1; char resp; printf("\nTabla del xD votado"); printf("\n***** *** **** ******\n"); //do //{ for(i=0;i<fil;i++) { printf("FACULTAD [%d]:",i); for(j=0;j<col;j++) { mat[i][j]=10+rand()%41; printf("%6d", mat[i][j]); votos[j]+=mat[i][j]; } printf("\n"); } printf("\nVOTOS TOTALES"); for(j=0;j<col;j++) printf("%6d",votos[j]); return 0; } 

    EDIT: PROBLEM SOLVED,

    //votos #include<stdio.h> #include<stdlib.h> #include<time.h> #include<ctype.h> #include<windows.h> #define fil 5 #define col 7 #define n 5 main(){ srand(time(NULL)); int mata[fil][col], i,j, vec[col], suma; char resp; printf("\n Registro de votos"); printf("\n ******** ** *****\n"); //do //{ printf("\nCandidatos "); for(j=0; j<col; j++) { printf("%6d", j+1); } printf("\n"); for(i=0; i<fil; i++) { printf("\nFacultad [%d]: ", i+1); for(j=0; j<col; j++) { mata[i][j]=10+rand()%41; printf("%6d", mata[i][j]); } printf("\n"); } printf("\n"); printf("\nTotal. Votos: "); for(j=0; j<col; j++) { suma=0; for(i=0; i<fil; i++) { suma+=mata[i][j]; } vec[j]=suma; } for(j=0; j<col; j++) { printf("%6d", vec[j]); } //}while(resp!='N'); return 0; } 

    submitted by /u/Tio_Rods420
    [link] [comments]

    No comments:

    Post a Comment