• Breaking News

    Saturday, March 10, 2018

    Need help with mono game in visual studio Ask Programming

    Need help with mono game in visual studio Ask Programming


    Need help with mono game in visual studio

    Posted: 10 Mar 2018 06:35 PM PST

    I've recently taken up Computer Programming, I am using Mono Game in visual studio on a mac. I decided to make a game for my little brothers centered around Carl Wheezer from Jimmy Neutron.(Long story, not important)

    Anyways, I have mostly been working on it at school in between class assignments. When I finished it, I put it on a thumb drive, and brought it home. I plugged it in, and it won't run on my mac, because its a windows based file. Fair enough, so I use the code in mac. Its the exact same commands, and just does mac. The only error I get is "The program does not contain a static main method suitable for an entry point".

    Its the exact same code that ran on my computer at school, and I know it works because some of the early versions are on my computer and run fine. Any help would be much appreciated, as this seems like a pretty simple fix, I just can't figure it out.

    Sorry, the code is pretty sloppy, and pretty long. A lot of the variable are a little weird too because I drew a lot of code from one we made at school.

    using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Audio; using System;

    namespace Carl_Wheezer { public class Game1 : Game { // Global Variables GraphicsDeviceManager graphics; SpriteBatch spriteBatch;

     int counter = 0; // Counts Game Cycles or How many times did Update() run. Color backColor; Texture2D back, ship, sh, plasma, rock; Rectangle backRec, shipRec, shRec, plasmaRec; const int howMany = 1; Rectangle[] pebbles = new Rectangle[howMany]; SoundEffect explosion, engine, phaser; SpriteFont font; GamePadState pad; int score = 0; float rotten = 0f; double speed = 0; int x = 0, y = 0, shotX = 0, shotY = 0; bool shot = false; int shieldTime = 1200; Random spot = new Random(); float op = 1.0f; public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; graphics.PreferredBackBufferWidth = 1500; graphics.PreferredBackBufferHeight = 900; } protected override void Initialize() { backRec = new Rectangle(0, 0, 1500, 900); shipRec = new Rectangle(600, 400, 70, 70); shRec = new Rectangle(); plasmaRec = new Rectangle(); for (int count = 0; count < howMany; count++) { pebbles[count] = new Rectangle(spot.Next(1300), spot.Next(700), 2, 2); } base.Initialize(); } protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); back = Content.Load<Texture2D>("space"); ship = Content.Load<Texture2D>("carl"); explosion = Content.Load<SoundEffect>("explosion"); engine = Content.Load<SoundEffect>("engine"); phaser = Content.Load<SoundEffect>("phaser"); sh = Content.Load<Texture2D>("breeze"); font = Content.Load<SpriteFont>("font"); plasma = Content.Load<Texture2D>("breeze"); rock = Content.Load<Texture2D>("ultralord"); } protected override void Update(GameTime gameTime) { pad = GamePad.GetState(0); if (pad.Buttons.Back == ButtonState.Pressed) Exit(); if (op > 0.5f) { Stars(); Ship(); Shield(); Shooting(); Rock(); Collisions(); } counter++; base.Update(gameTime); } private void Collisions() { for (int count = 0; count < howMany; count++) { //ship and asteroid if (shipRec.Intersects(pebbles[count]) && pad.Buttons.B == ButtonState.Released) { pebbles[count] = new Rectangle(spot.Next(1300), spot.Next(700), 2, 2); explosion.Play(); op -= 0.1f; } //asteroid and plasma if (pebbles[count].Intersects(plasmaRec)) { score++; explosion.Play(); pebbles[count] = new Rectangle(spot.Next(1300), spot.Next(700), 2, 2); } } } private void Rock() { for (int count = 0; count < howMany; count++) { pebbles[count].Height = pebbles[count].Width++; } } private void Shooting() { if (shot == false) { // Ready to shoot if (pad.Triggers.Right > 0.3 && (x != 0 || y != 0)) { shot = true; plasmaRec = shipRec; plasmaRec.X -= 35; plasmaRec.Y -= 35; plasmaRec.Inflate(-25, -25); phaser.Play(); shotX = x * 30; shotY = y * 30; } } else { //already shot plasmaRec.X += shotX; plasmaRec.Y -= shotY; } if (plasmaRec.Left > 1500 || plasmaRec.Right < 0 || plasmaRec.Top > 900 || plasmaRec.Bottom < 0) { plasmaRec = new Rectangle(); shot = false; } } private void Shield() { if (pad.Buttons.B == ButtonState.Pressed && shieldTime > 0) { shieldTime--; shRec = shipRec; shRec.X -= 35; shRec.Y -= 35; shRec.Inflate(10, 10); } else { shRec = new Rectangle(); } } private void Ship() { // SHIP ENGINES GamePad.SetVibration(0, pad.Triggers.Left, pad.Triggers.Left); // SHIP MOVEMENT speed = 10 + (25 * pad.Triggers.Left); if (pad.Buttons.A == ButtonState.Pressed) { speed = speed * 2; } x = (int)(speed * pad.ThumbSticks.Left.X); y = (int)(speed * pad.ThumbSticks.Left.Y); shipRec.X += x; shipRec.Y -= y; // SHIP Wrapping if (shipRec.Left > 1500) { shipRec.X = -70; } if (shipRec.Right < 0) { shipRec.X = 1500; } if (shipRec.Top > 900) { shipRec.Y = -70; } if (shipRec.Bottom < 0) { shipRec.Y = 900; } rotten = (float)(Math.Atan2(pad.ThumbSticks.Left.X,pad.ThumbSticks.Left.Y)); } private void Stars() { if (counter % 300 == 0) { backColor = Color.Blue; } if (counter % 300 == 15) { backColor = Color.White; } } protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(backColor); spriteBatch.Begin(); spriteBatch.Draw(back, backRec, Color.White); for (int count = 0; count < howMany; count++) { spriteBatch.Draw(rock, pebbles[count], Color.White); } spriteBatch.Draw(ship, shipRec, null, Color.White * op, rotten, new Vector2(337, 337), 0, 0f); spriteBatch.Draw(sh, shRec, Color.White * .5f); spriteBatch.Draw(plasma, plasmaRec, Color.White); spriteBatch.DrawString(font, score + "", new Vector2(10, 10), Color.White); spriteBatch.End(); base.Draw(gameTime); } } 

    }

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

    Alongside with php

    Posted: 10 Mar 2018 07:22 PM PST

    What are the things I have to master while learning php? E.g. rest api etc

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

    Employed programmers, what do employers want from me!?

    Posted: 10 Mar 2018 09:55 PM PST

    I am currently 8 weeks from graduating with my degree in CS. It will be my second bachelors attained at the ripe old age of 32. I shifted my career path from running family's business (bakery) to working in tech support (phone) to pay the bills, and going back to school to get my degree in CS with the eventual goal of working as a software engineer/developer (have a dream of working for Tesla someday -- #goals). School has taught me programming basics with Java (some C, C++, and JS/CSS/HTML): algorithms, data structures, architecture, graphics, etc. and I have been going through many of the practice interview questions (various sources) to be sure I will be somewhat prepared for a technical interview. I recently started working my way through freecodecamp so that I can add Javascript, CSS, HTML, Angular, React, etc,etc. to my resume with some sense of confidence. Is this type of preparation enough though?! Please take a look at my unpolished and beginner level portfolio that links to my github among other things and tell me if I am going in the right direction. (I know the 'project' photos aren't loading in right now - working on it)

    Here is the link to the portfolio I made as one of the beginner projects in freecodecamp (its a Pen at codePen.io) :

    https://codepen.io/darobbins85/pen/OQPLRN

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

    Parsing inconsistent JSON in Python

    Posted: 10 Mar 2018 08:26 PM PST

    Hi all, I have a JSON file that I'm downloading from a college athletics website. I simplified it here a bit, but the structure of the JSON is as follows before the game:

    [{ "date": "2018-03-04T00:00:00", "events": [{ "date": "2018-03-040", "time": "7:00 PM PT", "at_vs": "vs", "sport": { "title": "Baseball", "shortname": "bsb" }, "opponent": { "id": 678, "title": "State School", "mascot": "Bulldogs" }, "result": null }] }] 

    After the game, the results information populates in like this:

    [{ "date": "2018-03-04T00:00:00", "events": [{ "date": "2018-03-040", "time": "7:00 PM PT", "at_vs": "vs", "sport": { "title": "Baseball", "shortname": "bsb" }, "opponent": { "id": 678, "title": "State School", "mascot": "Bulldogs" }, "result": { "status": "W", "team_score": "5", "opponent_score": "2", "recap": { "title": "Recap", "url": "/news/2018/3/4/recap-article.aspx" } } }] }] 

    I'm getting a TypeError: 'NoneType' object is not subscriptable error when I parse before the game and it look for values in the results section. Is there an easy way to tell python to ignore results that are nonetype?

    I built in a catch for that if a given date doesn't have a value (the index is by date) by using the if field_list is None: line below:

    length = len(data) current = 0 while current < length: print('###DAY NUMBER ' + str(current) +'###') field_list = data[current]['events'] if field_list is None: print("No Events...\n") else: for fields in field_list: print(fields['sport']['title']) #(...) 

    Do I need to do something like that for each node within the data? Or is there a way to have that interpreted by a function? Maybe normalize it before getting here using something like Normalizr?

    PS, if you can't tell by my code, i'm not entirely sure what I"m doing, so please ELI5 as best you can. Thanks!

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

    [Haskell] Nested Loops

    Posted: 10 Mar 2018 07:49 PM PST

    For example, if I have this basic nested loop structure, how would I go about implementing this in Haskell?

    list = []

    for (int i = 0; i < 3; i++) {

     for (int j = 0; j < 3; j++) { if board[i][j] == Nothing list.append([i,j, 'X']) } 

    }

    return list

    Thanks!

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

    What is the difference between node js and javascript.

    Posted: 10 Mar 2018 09:30 AM PST

    As I understand it, you can write javascript in a text editor like sublime or atom but to use node you need to actually download it from the internet. What are you downloading and what is it allowing you to do that you can not do with vanilla js?

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

    What would be best way to create Google Calendar events from a Google sheet in my case?

    Posted: 10 Mar 2018 12:05 PM PST

    Im working on a home cleaning service booking sheet.

    https://docs.google.com/spreadsheets/d/1A82Pvm5f4z4mMZzOLIfgmsN_Xz4Xb6Otqgpjb0Zr3p8/edit#gid=0

    In it the vacation home rental owners can schedule the check in and check out dates for each property. So far so good.. Now I need to be able to send the check in and check out time and date with the name of the corresponding property to a Google Calendar.

    I would be able to use Google's CalendarAPP API to create the calendar entries with google sheet script editor.

    https://www.youtube.com/watch?v=w4oUjDC9L6A&list=PLv9Pf9aNgemv62NNC5bXLR0CzeaIj5bcw&index=11

    I've been told that I should

    "Get a 2 dimensional array from the Spreadsheet API using getRange(). The 2 dimensional array should be a Nx3 array, with the first column being the Date, second array being the check in time (if any), and the third array being the check out time (if any). Loop through the second column, and stop at each cell if the cell contains the value. Loop through the third column, starting at the row where the cell is at, until you find the first value. Combine each of the value (time) with the first column (date), and you would obtain the check in date/time and the check out date/time for each event."

    So far this is what I've come up with..

    function myFunction() {

    // Get spreadsheet values into an array

    var array = SpreadsheetApp.getActiveSheet().getRange("A3:D18").getDisplayValues();

    Logger.log(array);

    //beginning of array loop

    var i, len;

    for (i = 0, len = array.length, i < len; i++ {

    }

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

    How much do you know about XML? Do you feel like you understand it? Do you think it will ever come into favor again?

    Posted: 10 Mar 2018 04:38 PM PST

    Null Pointer Exception

    Posted: 10 Mar 2018 12:51 PM PST

    Hello all I'm trying to make a guess the celebrity app for android and keep running in to a null pointer exception

    here is my code

    public class MainActivity extends AppCompatActivity {

    ArrayList<String> celebURLS = new ArrayList<String>(); ArrayList<String> celebNames = new ArrayList<String>(); int chosenCeleb = 0; ImageView ivCeleb; public class ImageDownloader extends AsyncTask<String, Void, Bitmap> { @Override protected Bitmap doInBackground(String... urls) { try { URL url = new URL(urls[0]); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.connect(); InputStream inputStream = connection.getInputStream(); Bitmap myBitmap = BitmapFactory.decodeStream(inputStream); return myBitmap; } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } } public class DownloadTask extends AsyncTask<String, Void, String> { @Override protected String doInBackground(String... urls) { String result= ""; URL url ; HttpURLConnection urlConnection = null; try { url = new URL(urls[0]); urlConnection = (HttpURLConnection)url.openConnection(); InputStream in = urlConnection.getInputStream(); InputStreamReader reader = new InputStreamReader(in); int data = reader.read(); while (data != -1) { char current = (char) data; result += current; data = reader.read(); } return result; } catch (Exception e) { e.printStackTrace(); } return null; } } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ivCeleb = (ImageView)findViewById(R.id.ivCeleb); DownloadTask task = new DownloadTask(); String result = null; try { result = task.execute("http//www.posh24.se/Kandisar").get(); String[] splitResult = result.split("<div class=\"sidebarContainer\">"); Pattern p = Pattern.compile("src=\"(.*?)\""); Matcher m = p.matcher(splitResult[0]); while (m.find()) { celebURLS.add(m.group(1)); } p = Pattern.compile("alt=\"(.*?)\""); m = p.matcher(splitResult[0]); while (m.find()) { celebNames.add(m.group(1)); } Random random = new Random(); chosenCeleb = random.nextInt(celebURLS.size()); ImageDownloader imageTask = new ImageDownloader(); Bitmap celebImage; celebImage = imageTask.execute(celebURLS.get(chosenCeleb)).get(); ivCeleb.setImageBitmap(celebImage); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } } 

    } here is my log report

    FATAL EXCEPTION: main Process: com.example.sean.topcelebs, PID: 8419 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sean.topcelebs/com.example.sean.topcelebs.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String[] java.lang.String.split(java.lang.String)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6494) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String[] java.lang.String.split(java.lang.String)' on a null object reference at com.example.sean.topcelebs.MainActivity.onCreate(MainActivity.java:130) at android.app.Activity.performCreate(Activity.java:7009) at android.app.Activity.performCreate(Activity.java:7000) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6494) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

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

    I need help with encryptions

    Posted: 10 Mar 2018 08:55 AM PST

    So i want to write a encryption software but i'm having trouble with the password thing as a key. If Key= Y And Data= X does Y*X= Encrypted data work cause I have a feeling that is easely broken, but I'm really stuck. If someone can point to my stupidity it would be verry helpful.

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

    Program to help with the design stage?

    Posted: 10 Mar 2018 04:14 PM PST

    I'm wondering if anyone has suggestions for programs which would help with designing my game. Basically, probably just looking for a brainstorming tool. I have been working through Head First Design Patterns, and the diagrams they use to map out classes and interactions have been super helpful. Any suggestions appreciated!

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

    Help - Hi or Low Card Game

    Posted: 10 Mar 2018 08:35 AM PST

    Hey all, I'm on a fundamentals course and we've had very little in the way of delivery in our programming unit. I have a task to create a higher or lower card game. Was thinking that Javascript/PHP would be a good way to go; As anyone seen any good tutorials or learning platforms for this specific kinda task?

    I have a little bit of understanding of both but nothing which would allow me to make it with cards (I've made a random number higher/lower in php but this is far short of the task required)

    Any advice/help would be fantastic.

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

    A question I remember from a programming challenge some time ago:

    Posted: 10 Mar 2018 12:14 PM PST

    Essentially, the idea goes like this:

    Three cyclists are cycling down the center of a road that is x meters wide at a speed of k meters/second. Each cyclist can be represented as a line segment of length y, and they have a common distance of z meters between each other.

    A dog, represented by a circle of radius r, wants to run across the road. At a given start time b, the cyclists always start moving from a given distance c away. If you are also given the time the dog starts moving (d), then:

    1) How do you detect if there is a collision?

    2) How would you tell if the dog went before the cyclists, after the cyclists, or in between two specific cyclists?

    Sorry for the long-winded scenario. How would this be solved?

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

    Want to be able to "draw" a line

    Posted: 10 Mar 2018 03:43 PM PST

    So i have an ImageView[][] in a gridpane and if you hover over an image it changes colors but when i go outside the gridpane and hit an image it also changes. So i only want to be able to color the images next to the already colored image. But i can seem to find a solution. Hope someone can help me here

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

    What's a nice simple program to write for your crush/love?

    Posted: 10 Mar 2018 06:17 AM PST

    Some simple, cute ideas. I really like this girl lol

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

    Questions about writing a Doom/Duke Nukem 3D-like engine for the web

    Posted: 10 Mar 2018 10:12 AM PST

    I'm following along with this video, trying to make a sector-based 3D engine in javascript. What I've got so far uses the canvas API. It hiccups when the walls are a solid color, and slows to a stop when I add texturing. Here's a pen: https://codepen.io/cpcolt/pen/rdaRGW?editors=1010 Really messy at the moment, but gives you an idea about what it looks like. How well does the pen run on your computer? On my laptop it stutters and hangs.

    Is it even possible to have a Build-like engine running say, 60fps, in a browser?

    Should I write it with PixiJS? Web Assembly?

    submitted by /u/-_---__-___
    [link] [comments]

    Good book about sites and apps like TreeHouse?

    Posted: 10 Mar 2018 06:01 AM PST

    Hello. I was looking for articles, books and such abut sites which help users with their learning (like DuoLingoo or TreeHouse). However i found only a couple of online articles. Does anyone know a good book about this topic? Thanks

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

    A good cloud architecture conventions in Europe?

    Posted: 10 Mar 2018 02:44 AM PST

    I'm looking for a good convention in Europe, such as Amsterdam, Berlin, or other interesting city. Preferably a place for good networking.

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

    Is this a valid concept for my server/client program?

    Posted: 10 Mar 2018 02:37 AM PST

    I want to develop a very simple game that relies largely on database work. I have never done anything of the sort, so I don't know what the best approach is.

    The current way I see of making this project as simple as possible for me is running a local mySQL server to manage the database next to the Server.exe and let Client.exe connect to Server.exe.

    This is all that I want to have happen:
    Server.exe runs a bunch of functions with the local database on a schedule, say once per 24h.
    Client.exe can modify user specific data at any time to influence the scheduled functions and get a lot of small datasets from the database on demand.

    Thanks for any advice.

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

    No comments:

    Post a Comment