Game Maker Studio HTML5 Text displaying problem - game-maker-language

In Game Maker Studio 2 text object is poorly displayed when i exporting my game to HTML5
DRAW event:
draw_set_font(fnt0);
draw_set_alpha(1);
draw_set_color(c_white);
draw_set_halign(fa_left);
draw_set_valign(fa_top);
draw_text_ext(x+24,y+16,msg,16,boxWidth);
Text in msg is defined in the STEP event and depends on the state (gameState) of the game.
switch gameState
{
case gameState.titleScreen:
scrTitleScreen();
break;
case gameState.charGen:
scrCharGen();
break;
}
gameState is defined in ENUM.
Tested in Opera browser 56.0.3051.99.
Any help? Thanks!

Related

How to write code to show who has won the game

i have made a cannon shooting game for two player, the aim is to break the castle down and then try to land the cannon ball onto the opponent but the problem is idk how to write code to show who has won the game when the game is over and all i know is that the code will need to written in the game over section & I am new to code as well
void CMyGame::OnUpdate()
{
if (m_mode == MODE_SHOOT)
{
/////////////////////////////////////////////////
// this code will only be executed while shooting
// TODO: 1. Add the gravitation
m_ball.Accelerate(0, -8);
// TODO: 2. Check if cannon hit? game over?
if (m_ball.HitTest(m_cannons[1 - m_turn]))
{
GameOver();
}
// TODO: 3. Check if the ball is outside the screen. Test the following cases:
// - ball to the left of the screen
if (m_ball.GetX() < 0)
NextTurn();
// - ball to the right of the screen (screen width = 800)
if (m_ball.GetX() > 800)
NextTurn();
// - ball below the screen
if (m_ball.GetY() < 0)
NextTurn();
// TODO: 4. Check if the ball hit the castle?
for each (CSprite * pSprite in m_castle)
{
if (m_ball.HitTest(pSprite))
NextTurn();
}
}
// Check if the castle has taken damage
for (CSprite* pSprite : m_castle)
{
if (m_ball.HitTest(pSprite))
pSprite->Delete();
}
m_castle.delete_if(deleted);
// Update the ball's position
m_ball.Update(GetTime());
the part i need help on is how to write code that will show who has won the game
// called when Game is Over
void CMyGame::OnGameOver()
{
m_cannons[1 - m_turn]->SetImage("fire");
m_mode = MODE_GAMEOVER;
}
Hard to say without seeing the rest of your code and info on how your game works, but you can follow something like this:
Assuming you can check when a cannon lands somewhere and can track the % hit points of each player (which I believe you can do considering you have gravity planned in your given code):
Write a function which is called each time a cannon ball lands, check if the ball has dealt the final blow on the opponent's character. From what you say, you probably do not need to do this check until the castle has been broken down. So something along the lines of if(!castleBroken) {return;} at the start of the function would only check the opponent's HP if the castle is broken (again, assuming that the opponent can only take damage if the castle is broken). Here, castleBroken is a bool which starts as false and becomes true when the cannon has broken the opponent's castle.
This is a similar idea to a Tic-Tac-Toe game I wrote in the past, where after each move, I would check the board state. If the game was over, the game over screen would be printed with the winner declared, or in some cases, a draw.

Godot indexing and keyboard both at the same time

I have been trying to develop keyboard and touch indexed game, playable on PC browsers and phone. How can I index?
Tried some samples in Godot Sample menu. None of them helped. Either for keyboard or touch screen
func _unhandled_input(event):
if event is InputEventScreenTouch:
if event.pressed:
# Down
if !_os2own.has(event.index): # Defensively discard index if already known
var ptr_id = _find_free_pointer_id()
state[ptr_id] = event.position
_os2own[event.index] = ptr_id
else:
# Up
if _os2own.has(event.index): # Defensively discard index if not known
var ptr_id = _os2own[event.index]
state.erase(ptr_id)
_os2own.erase(event.index)
return true
Need to touching and clicking game. Both for APK and HTML
For simple input handling (e.g. pressed and released) you'll want to map input to actions. You can add actions via "Project Settings -> Input Map" or InputMap singleton.
From the "Project Settings -> Input Map" you can map mouse, keyboard, and controller input to actions.
For touch screens you can use a TouchScreenButton and set it's action. When pressed or released it will send that action event down the scene tree via _input(). TouchScreenButton hides the logic needed to write in _input() to handle presses and releases, such as: is this finger index new? which finger index moved last frame? is this finger area in bounds of input area? and more. While also having the advantage over a plain Button by also emitting an action and can have no texture as it uses a Shape for input detection.
So this creates an one-to-many relationship from actions to inputs like:
my_action -> left mouse button pressed,
-> controller r1 pressed,
-> right half of touch screen pressed,
-> control-shift-f pressed
Using the action
func _input(event):
if not event.is_action('my_action'):
return
if event.is_action_pressed('my_action'):
start_something()
else:
stop_something()
Going further
Since the post specified keyboard and touch input, I only covered press and release input action mapping. However, you can map complex inputs like gestures to actions as well. You can inherit from InputEvent or any of it's subclasses to extend or create a new event. You can map the new event class to an action and then manually process input to find an event. Then you stop the propagation of the event, form the event from your new event class, and then call Input.parse_input_event(my_new_event) to send it down the tree.
Custom Action
# SomeLeafNode.gd
class MyEvent extends InputEvent:
var my_custom_message = 'Hello, World'
func _ready():
InputMap.add_action('my_event')
InputMap.action_add_event('my_event', MyEvent.new())
func _input(event):
# ... logic to see if event could be MyEvent
get_tree().set_input_as_handled()
var my_event = MyEvent.new()
my_event.my_custom_message = 'Caught my event!'
Input.parse_input_event(my_event)
# SomeInputHandlingGameplayNode.gd
func _input(event):
if event.is_action('my_event'):
print(event.my_custom_message) # prints 'Caught my event!'

NSSplitViewItem collapse animation and window setFrame conflicting

I am trying to make a (new in 10.10) NSSplitViewItem collapse and uncollapse whilst moving its containing window so as to keep the whole thing "in place".
The problem is that I am getting a twitch in the animation (as seen here).
The code where I'm doing the collapsing is this:
func togglePanel(panelID: Int) {
if let splitViewItem = self.splitViewItems[panelID] as? NSSplitViewItem {
// Toggle the collapsed state
NSAnimationContext.runAnimationGroup({ context in
// special case for the left panel
if panelID == 0 {
var windowFrame = self.view.window.frame
let panelWidth = splitViewItem.viewController.view.frame.width
if splitViewItem.collapsed {
windowFrame.origin.x -= panelWidth
windowFrame.size.width += panelWidth
} else {
windowFrame.origin.x += panelWidth
windowFrame.size.width -= panelWidth
}
self.view.window.animator().setFrame(windowFrame, display: true)
}
splitViewItem.animator().collapsed = !splitViewItem.collapsed
}, completionHandler: nil)
}
}
I am aware of the "Don't cross the streams" issue (from session 213, WWDC'13) where a window resizing animation running on the main thread and a core animation collapse animation running on a separate thread interfere with each other. Putting the splitViewItem collapse animation onto the main thread seems like the wrong approach and I've got a nagging feeling there's a much better way of doing this that I'm missing.
Since I am not finding any documentation on the NSSplitViewItems anywhere (yet) I would appreciate any insights on this.
I have the little test project on GitHub here if anyone wants a look.
Update The project mentioned has now been updated with the solution.
Thanks,
Teo
The problem is similar to the "don't cross the streams" issue in that there are two drivers to the animation you've created: (1) the split view item (2) the window, and they're not in sync.
In the example from the '13 Cocoa Animations talk, constraints were setup to result in the correct within-window animation as only the window's frame was animated.
Something similar could be tried here -- only animating the window's frame and not the split view item, but since the item manages the constraints used to (un)collapse, the app can't control exactly how within-window content animates:
Instead the split view item animation could completely drive the animation and use NSWindow's -anchorAttributeForOrientation: to describe how the window's frame is affected.
if let splitViewItem = self.splitViewItems[panelID] as? NSSplitViewItem {
let window = self.view.window
if panelID == 0 {
// The Trailing edge of the window is "anchored", alternatively it could be the Right edge
window.setAnchorAttribute(.Trailing, forOrientation:.Horizontal)
}
splitViewItem.animator().collapsed = !splitViewItem.collapsed
}
For anyone using Objective C and targeting 10.11 El Capitan.
This did the trick for me, didn't need to set AnchorAttributes.
splitViewItem.collapsed = YES;

IOS 6.0 MKAnnotation callout bubble strange behavior

I resently faced some strange issue on IOS 6.0 related to MKAnnotation (part of MKMap Kit)
May be some of you fased the same, or have idea or advise how to skip/avoid/solve it.
Here it is
I need some Pins on my map with callout bubbles (contains titles & subtitles nothing more)
When i pressing on it callout starts. Due to user comfort I've added observer to center pin:
(void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context{
NSString *action = (NSString*)context;
if([[change valueForKey:#"new"] intValue] == 1 && [action isEqualToString:#"GMAP_ANNOTATION_SELECTED"]) {
if ([((MKAnnotationView*) object).annotation isKindOfClass:[CustomPlacemark class]]) {
CustomPlacemark *place = ((MKAnnotationView*) object).annotation;
[mapView setCenterCoordinate:place.coordinate animated:YES];
}
}
}
On ios 5.1 or above everything looks & works fine (pin centering after press, callout bubbles shows above centered horizontally), but on IOS 6.0 behavior is strage, pin centering as well, but callout bubble not, even if it's width enough to fill screen horizontally it could appear partially beyond screen.
Haven't found any solution or options to manually setup appearance behavior. Have any advices?
Thx for further answers, and sorry for my English.

Nokia N97 realted to orientation

Myself shweta dodiya.I am facing problem with nokia N97 related to change orientation for my game application.
I am using J2me technology.I want to pause my application when i open my slider.
Thanks in advance
I don't know what code are you using, or are you using Canvas to draw the game on screen, or some other API that does that for you...
If you have something like this GameScreen extends Canvas and you use GameScreen object to draw and display the game, you need to add an override to sizeChanged method to it and check the new width (w) and the new height (h) of the GameScreen, and do the things you want in regards to that:
public void sizeChanged(int w, int h)
{
if(h > w) //NORMAL
{
drawGame();
if(paused) resumeGame();
}
else //LANDSCAPE
{
pauseGame();
drawPauseScreen();
}
}
This is a simple pseudo code, I hope you are getting the point. If statement is checking the relation between new width and the new height. If the phone is in landscape mode, H is less then W...

Resources