2d

Location of Largest Number in an Array

£可爱£侵袭症+ 提交于 2019-12-13 05:53:50
问题 My program is supposed to prompt the user to input the number of rows and columns in an array and then input the array. The location of the largest element in the array is then calculated and displays. My code keeps displaying (0,1) instead of the actual result, (1,2). Any ideas? My code: import java.util.Scanner; public class Question8_13 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the number of rows and columns in the array: ");

Pygame collision interaction

牧云@^-^@ 提交于 2019-12-13 05:11:27
问题 Here is my code: import pygame, sys from pygame.locals import * try: import Android except ImportError: Android = None try: import pygame.mixer as mixer except ImportError: import android.mixer as mixer pygame.init() #Android to cross platform if Android: android.init() android.map_key(android.KEYCODE_BACK, pygame.K_ESCAPE) #Variables score = 0 health = 100 #Colours RED = (255 ,0 ,0) BLACK = (0, 0, 0) # Left Edge of rectangle, top, width, height player_rect = pygame.Rect(540, 0, 32, 32) enemy

Accelerometer - Rolling Ball in Ball

眉间皱痕 提交于 2019-12-13 04:41:50
问题 i want to use the phones accelerometer for rolling a Ball in a Ball. The movement works correctly, the problem is that when the ball hits the Wall. How can i get a smooth rolling animation that the ball slides along the inner side of the bigger ball? This is my current code to move the Ball and check the intersection: onSuccess: function(acceleration) { var xPos = this.xPos + (-1 * (acceleration.x * 0.5)); var yPos = this.yPos + (acceleration.y * 0.5); var intersect = this.intersection(xPos +

Issue with Canvas.rotate() in Android .How does it exactly work?

别说谁变了你拦得住时间么 提交于 2019-12-13 04:39:37
问题 Please find the code of my onDraw method below(.I'm trying to rotate the canvas(//Rotate call -b) by 25 degrees after drawing the arc .But i find that the arc is still drawn from 0 to 50 degrees.I was expecting it to move by another 25 degrees. public class CustomView extends View { public CustomView(Context context) { super(context); } public CustomView(Context context, AttributeSet attrs) { super(context, attrs); } protected void onDraw(Canvas canvas) { super.onDraw(canvas); Paint paint =

Why Aren't My Tile Maps Displaying Correctly?

荒凉一梦 提交于 2019-12-13 04:38:43
问题 I am trying to load and render levels (tile maps) in Slick2D from text files. The text files look something like this: res/RPGSheet 32x32.png (tileset to be used with this map) 5 (How many tiles wide the map is) 5 (How many tiles tall the map is) 16 (How many tiles wide the tileset is) 16 (How many tiles tall the tileset is) 4,1 4,1 4,1 4,1 4,1 4,1 1,1 2,0 4,1 4,1 4,1 4,1 1,1 4,1 4,1 4,1 1,1 4,1 1,1 4,1 4,1 4,1 4,1 4,1 4,1 First I'll explain how my tilemaps work: Each coordinate indicates

How do you tell libgdx to use a specific color for transparency?

感情迁移 提交于 2019-12-13 04:38:18
问题 I use GraphicsGale and it doesn't support transparency. The easy fix for this problem is to just use a really ugly color (#808040 in my case) and use that for transparency. I haven't been able to find a way how to do this in libgdx though. I can of course just pull it through GIMP and fill in the transparency, but it would be nice to work straight out of GraphicsGale. So my question is, is there a way to make libgdx treat a color as transparency, and if there is, how? 回答1: I modularized my

How to add a string to a 2D array in C

瘦欲@ 提交于 2019-12-13 04:32:30
问题 i am starting to learn C and I have ran into the problem of adding a string input to a 2D array, i am able to get the string input correctly but when i try and add the string element to the array it is not working as expected.When printing the array(which is how i test the program) it will assign each index in the array a single character instead of the entire string. And here is my code for viewing, thank you very much in advance i appreciate any help that is posted. #include <stdio.h> main(

Using a swap function to swap the address in pointers of a 2D-array

╄→гoц情女王★ 提交于 2019-12-13 04:19:01
问题 For an assignment I need to make a sorting algorithm for n amount of vector arrays. The assignment specifically tells me to not swap the value of what the pointers are pointing to, but the address that is stored in those pointers. The result will then be printed using those pointers. My problem is that I can't seem to accomplish the swapping of the addresses that the pointers contain. I have searched SO for related questions but they almost all change the values of where the pointers are

AS3: Viewports without an end

↘锁芯ラ 提交于 2019-12-13 04:02:13
问题 I'm making a space navigation game. So it starts with the user on the spaceship and then when he press the up key the ship goes forward, the 'map' is always different, I have 5 variations of stars and 2 variations of planets, so they basically 'spawn' randomly while the user navigates. I can make the key detection, the movie clips generator code, but I don't know how do I make the navigation code, I mean how do I make the viewport move when the user press the key, ... I've saw a code that I

2d dynamic array (in C) with specific row number and different column size in each row

纵饮孤独 提交于 2019-12-13 03:59:20
问题 How do I make a 2d dynamic array (in C) with specific row number and different column size in each row? For example: This is an array (3=rows) |1 | 4 | 5 | |3 | |6 | 2 | 1st row - 3 columns 2nd row - 1 column 3rd row - 2 columns I want my program while running to ask the user for every row to give the number of cols. How do I make an array like this? 回答1: If you want something dynamic and don't care about constant access time, you can create an array of linked list, otherwise you have no